diff --git a/bricktracker/configuration.py b/bricktracker/configuration.py index d5c561b..6542b57 100644 --- a/bricktracker/configuration.py +++ b/bricktracker/configuration.py @@ -16,6 +16,7 @@ class BrickConfiguration(object): def __init__( self, /, + *, n: str, e: str | None = None, d: Any = None, diff --git a/bricktracker/instructions.py b/bricktracker/instructions.py index 622fdc3..e70f484 100644 --- a/bricktracker/instructions.py +++ b/bricktracker/instructions.py @@ -71,7 +71,7 @@ class BrickInstructions(object): ) # Compute the path of an instruction file - def path(self, /, filename=None) -> str: + def path(self, /, *, filename=None) -> str: if filename is None: filename = self.filename @@ -99,7 +99,7 @@ class BrickInstructions(object): # Upload a new instructions file def upload(self, file: FileStorage, /) -> None: - target = self.path(secure_filename(self.filename)) + target = self.path(filename=secure_filename(self.filename)) if os.path.isfile(target): raise ErrorException('Cannot upload {target} as it already exists'.format( # noqa: E501 diff --git a/bricktracker/instructions_list.py b/bricktracker/instructions_list.py index 4d447b9..c60b742 100644 --- a/bricktracker/instructions_list.py +++ b/bricktracker/instructions_list.py @@ -18,7 +18,7 @@ class BrickInstructionsList(object): sets_total: int unknown_total: int - def __init__(self, /, force=False): + def __init__(self, /, *, force=False): # Load instructions only if there is none already loaded all = getattr(self, 'all', None) diff --git a/bricktracker/minifigure.py b/bricktracker/minifigure.py index afe5463..25db952 100644 --- a/bricktracker/minifigure.py +++ b/bricktracker/minifigure.py @@ -23,6 +23,7 @@ class BrickMinifigure(BrickRecord): def __init__( self, /, + *, brickset: 'BrickSet | None' = None, record: Row | dict[str, Any] | None = None, ): @@ -149,6 +150,7 @@ class BrickMinifigure(BrickRecord): def from_rebrickable( data: dict[str, Any], /, + *, brickset: 'BrickSet | None' = None, **_, ) -> dict[str, Any]: diff --git a/bricktracker/minifigure_list.py b/bricktracker/minifigure_list.py index 971fc6f..dfebc16 100644 --- a/bricktracker/minifigure_list.py +++ b/bricktracker/minifigure_list.py @@ -42,7 +42,7 @@ class BrickMinifigureList(BrickRecordList[BrickMinifigure]): return self # Last added minifigure - def last(self, /, limit: int = 6) -> Self: + def last(self, /, *, limit: int = 6) -> Self: # Randomize if current_app.config['RANDOM']: order = 'RANDOM()' @@ -89,6 +89,7 @@ class BrickMinifigureList(BrickRecordList[BrickMinifigure]): part_num: str, color_id: int, /, + *, element_id: int | None = None, ) -> Self: # Save the parameters to the fields @@ -113,6 +114,7 @@ class BrickMinifigureList(BrickRecordList[BrickMinifigure]): part_num: str, color_id: int, /, + *, element_id: int | None = None, ) -> Self: # Save the parameters to the fields diff --git a/bricktracker/part.py b/bricktracker/part.py index dd71bbb..da62943 100644 --- a/bricktracker/part.py +++ b/bricktracker/part.py @@ -27,6 +27,7 @@ class BrickPart(BrickRecord): def __init__( self, /, + *, brickset: 'BrickSet | None' = None, minifigure: 'BrickMinifigure | None' = None, record: Row | dict[str, Any] | None = None, @@ -83,6 +84,7 @@ class BrickPart(BrickRecord): part_num: str, color_id: int, /, + *, element_id: int | None = None ) -> Self: # Save the parameters to the fields @@ -112,6 +114,7 @@ class BrickPart(BrickRecord): brickset: 'BrickSet', id: str, /, + *, minifigure: 'BrickMinifigure | None' = None, ) -> Self: # Save the parameters to the fields @@ -250,6 +253,7 @@ class BrickPart(BrickRecord): def from_rebrickable( data: dict[str, Any], /, + *, brickset: 'BrickSet | None' = None, minifigure: 'BrickMinifigure | None' = None, **_, diff --git a/bricktracker/part_list.py b/bricktracker/part_list.py index 3932d8e..45a927f 100644 --- a/bricktracker/part_list.py +++ b/bricktracker/part_list.py @@ -49,6 +49,7 @@ class BrickPartList(BrickRecordList[BrickPart]): self, brickset: 'BrickSet', /, + *, minifigure: 'BrickMinifigure | None' = None, ) -> Self: # Save the brickset and minifigure diff --git a/bricktracker/rebrickable.py b/bricktracker/rebrickable.py index 312797a..16b947a 100644 --- a/bricktracker/rebrickable.py +++ b/bricktracker/rebrickable.py @@ -34,6 +34,7 @@ class Rebrickable(Generic[T]): number: str, model: Type[T], /, + *, socket: 'BrickSocket | None' = None, brickset: 'BrickSet | None' = None, minifigure: 'BrickMinifigure | None' = None @@ -113,7 +114,7 @@ class Rebrickable(Generic[T]): return results # Load from the API - def load(self, /, parameters: dict[str, Any] = {}) -> dict[str, Any]: + def load(self, /, *, parameters: dict[str, Any] = {}) -> dict[str, Any]: # Inject the API key parameters['api_key'] = current_app.config['REBRICKABLE_API_KEY'] diff --git a/bricktracker/rebrickable_image.py b/bricktracker/rebrickable_image.py index d0a07ec..eee3441 100644 --- a/bricktracker/rebrickable_image.py +++ b/bricktracker/rebrickable_image.py @@ -25,6 +25,7 @@ class RebrickableImage(object): self, brickset: 'BrickSet', /, + *, minifigure: 'BrickMinifigure | None' = None, part: 'BrickPart | None' = None, ): diff --git a/bricktracker/rebrickable_parts.py b/bricktracker/rebrickable_parts.py index 6ef9abb..b2f252f 100644 --- a/bricktracker/rebrickable_parts.py +++ b/bricktracker/rebrickable_parts.py @@ -29,6 +29,7 @@ class RebrickableParts(object): socket: 'BrickSocket', brickset: 'BrickSet', /, + *, minifigure: 'BrickMinifigure | None' = None, ): # Save the socket diff --git a/bricktracker/rebrickable_set.py b/bricktracker/rebrickable_set.py index 329c411..366bef0 100644 --- a/bricktracker/rebrickable_set.py +++ b/bricktracker/rebrickable_set.py @@ -104,6 +104,7 @@ class RebrickableSet(object): self, data: dict[str, Any], /, + *, from_download=False, ) -> BrickSet | None: # Reset the progress diff --git a/bricktracker/record.py b/bricktracker/record.py index a98db0d..27f2103 100644 --- a/bricktracker/record.py +++ b/bricktracker/record.py @@ -24,7 +24,7 @@ class BrickRecord(object): # Insert into the database # If we do not commit immediately, we defer the execute() call - def insert(self, /, commit=True) -> None: + def insert(self, /, *, commit=True) -> None: database = BrickSQL() rows, q = database.execute( self.insert_query, @@ -40,7 +40,7 @@ class BrickRecord(object): return self.fields.__dict__.items() # Get from the database using the query - def select(self, /, override_query: str | None = None) -> Row | None: + def select(self, /, *, override_query: str | None = None) -> Row | None: if override_query: query = override_query else: diff --git a/bricktracker/record_list.py b/bricktracker/record_list.py index 093d73b..48775d2 100644 --- a/bricktracker/record_list.py +++ b/bricktracker/record_list.py @@ -32,6 +32,7 @@ class BrickRecordList(Generic[T]): def select( self, /, + *, override_query: str | None = None, order: str | None = None, limit: int | None = None, diff --git a/bricktracker/retired_list.py b/bricktracker/retired_list.py index 78c3a68..231c472 100644 --- a/bricktracker/retired_list.py +++ b/bricktracker/retired_list.py @@ -22,7 +22,7 @@ class BrickRetiredList(object): size: int | None exception: Exception | None - def __init__(self, /, force: bool = False): + def __init__(self, /, *, force: bool = False): # Load sets only if there is none already loaded retired = getattr(self, 'retired', None) diff --git a/bricktracker/set.py b/bricktracker/set.py index f2cb9f8..100896e 100644 --- a/bricktracker/set.py +++ b/bricktracker/set.py @@ -26,6 +26,7 @@ class BrickSet(BrickRecord): def __init__( self, /, + *, record: Row | dict[str, Any] | None = None, ): super().__init__() diff --git a/bricktracker/set_list.py b/bricktracker/set_list.py index 41d94a6..e543b5b 100644 --- a/bricktracker/set_list.py +++ b/bricktracker/set_list.py @@ -58,7 +58,7 @@ class BrickSetList(BrickRecordList[BrickSet]): return self # Last added sets - def last(self, /, limit: int = 6) -> Self: + def last(self, /, *, limit: int = 6) -> Self: # Randomize if current_app.config['RANDOM']: order = 'RANDOM()' @@ -76,7 +76,7 @@ class BrickSetList(BrickRecordList[BrickSet]): def missing_minifigure( self, fig_num: str, - /, + / ) -> Self: # Save the parameters to the fields self.fields.fig_num = fig_num @@ -98,6 +98,7 @@ class BrickSetList(BrickRecordList[BrickSet]): part_num: str, color_id: int, /, + *, element_id: int | None = None, ) -> Self: # Save the parameters to the fields @@ -120,7 +121,7 @@ class BrickSetList(BrickRecordList[BrickSet]): def using_minifigure( self, fig_num: str, - /, + / ) -> Self: # Save the parameters to the fields self.fields.fig_num = fig_num @@ -142,6 +143,7 @@ class BrickSetList(BrickRecordList[BrickSet]): part_num: str, color_id: int, /, + *, element_id: int | None = None, ) -> Self: # Save the parameters to the fields diff --git a/bricktracker/socket.py b/bricktracker/socket.py index 8b7a25f..52bb4f6 100644 --- a/bricktracker/socket.py +++ b/bricktracker/socket.py @@ -140,6 +140,7 @@ class BrickSocket(object): def auto_progress( self, /, + *, message: str | None = None, increment_total=False, ) -> None: @@ -203,7 +204,7 @@ class BrickSocket(object): sql_close() # Update the progress - def progress(self, /, message: str | None = None) -> None: + def progress(self, /, *, message: str | None = None) -> None: # Save the las message if message is not None: self.progress_message = message @@ -218,14 +219,14 @@ class BrickSocket(object): self.emit('PROGRESS', data) # Update the progress total only - def update_total(self, total: int, /, add: bool = False) -> None: + def update_total(self, total: int, /, *, add: bool = False) -> None: if add: self.progress_total += total else: self.progress_total = total # Update the total - def total_progress(self, total: int, /, add: bool = False) -> None: + def total_progress(self, total: int, /, *, add: bool = False) -> None: self.update_total(total, add=add) self.progress() diff --git a/bricktracker/sql.py b/bricktracker/sql.py index 18c6c94..fd68522 100644 --- a/bricktracker/sql.py +++ b/bricktracker/sql.py @@ -35,7 +35,7 @@ class BrickSQL(object): stats: BrickSQLStats version: int - def __init__(self, /, failsafe: bool = False): + def __init__(self, /, *, failsafe: bool = False): # Instantiate the database connection in the Flask # application context so that it can be used by all # requests without re-opening connections @@ -147,9 +147,10 @@ class BrickSQL(object): self, query: str, /, + *, parameters: dict[str, Any] = {}, defer: bool = False, - **context, + **context: Any, ) -> Tuple[int, str]: # Stats: execute self.stats.execute += 1 @@ -172,7 +173,7 @@ class BrickSQL(object): return result.rowcount, query # Shorthand to executescript - def executescript(self, query: str, /, **context) -> None: + def executescript(self, query: str, /, **context: Any) -> None: # Load the query query = self.load_query(query, **context) @@ -187,8 +188,9 @@ class BrickSQL(object): self, query: str, /, + *, parameters: dict[str, Any] = {}, - **context, + **context: Any, ) -> Tuple[int, str]: rows, query = self.execute(query, parameters=parameters, **context) self.commit() @@ -200,8 +202,9 @@ class BrickSQL(object): self, query: str, /, + *, parameters: dict[str, Any] = {}, - **context, + **context: Any, ) -> list[sqlite3.Row]: _, query = self.execute(query, parameters=parameters, **context) @@ -221,8 +224,9 @@ class BrickSQL(object): self, query: str, /, + *, parameters: dict[str, Any] = {}, - **context, + **context: Any, ) -> sqlite3.Row | None: _, query = self.execute(query, parameters=parameters, **context) @@ -245,7 +249,7 @@ class BrickSQL(object): return defer # Load a query by name - def load_query(self, name: str, /, **context) -> str: + def load_query(self, name: str, /, **context: Any) -> str: # Grab the existing environment if it exists environment = getattr(g, G_ENVIRONMENT, None) @@ -276,7 +280,7 @@ class BrickSQL(object): self, query: str, parameters: dict[str, Any], - /, + / ) -> sqlite3.Cursor: logger.debug('SQLite3: execute: {query}'.format( query=BrickSQL.clean_query(query) diff --git a/bricktracker/sql_counter.py b/bricktracker/sql_counter.py index 77c5dd8..44c9733 100644 --- a/bricktracker/sql_counter.py +++ b/bricktracker/sql_counter.py @@ -4,7 +4,7 @@ class BrickCounter(object): icon: str count: int - def __init__(self, name: str, table: str, /, icon: str = ''): + def __init__(self, name: str, table: str, /, *, icon: str = ''): self.name = name self.table = table self.icon = icon diff --git a/bricktracker/theme_list.py b/bricktracker/theme_list.py index 160530c..22cac8e 100644 --- a/bricktracker/theme_list.py +++ b/bricktracker/theme_list.py @@ -22,7 +22,7 @@ class BrickThemeList(object): size: int | None exception: Exception | None - def __init__(self, /, force: bool = False): + def __init__(self, /, *, force: bool = False): # Load themes only if there is none already loaded themes = getattr(self, 'themes', None) diff --git a/bricktracker/wish.py b/bricktracker/wish.py index 3851562..ad8ab80 100644 --- a/bricktracker/wish.py +++ b/bricktracker/wish.py @@ -17,6 +17,7 @@ class BrickWish(BrickSet): def __init__( self, /, + *, record: Row | dict[str, Any] | None = None, ): # Don't init BrickSet, init the parent of BrickSet directly