From f493f0ea6d9d4967bc8d35ed242f37e403ab0a31 Mon Sep 17 00:00:00 2001 From: Patrick Ogenstad Date: Thu, 17 Oct 2024 20:46:23 +0200 Subject: [PATCH] Fix linting issues --- infrahub_sdk/schema.py | 4 +--- infrahub_sdk/transfer/importer/json.py | 4 ++-- pyproject.toml | 11 ++++++----- tests/integration/test_object_store.py | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/infrahub_sdk/schema.py b/infrahub_sdk/schema.py index 4aab453f..3d7f5797 100644 --- a/infrahub_sdk/schema.py +++ b/infrahub_sdk/schema.py @@ -983,6 +983,4 @@ class SchemaLoadResponse(BaseModel): @property def schema_updated(self) -> bool: - if self.hash and self.previous_hash and self.hash != self.previous_hash: - return True - return False + return bool(self.hash and self.previous_hash and self.hash != self.previous_hash) diff --git a/infrahub_sdk/transfer/importer/json.py b/infrahub_sdk/transfer/importer/json.py index 6829f762..1da225fa 100644 --- a/infrahub_sdk/transfer/importer/json.py +++ b/infrahub_sdk/transfer/importer/json.py @@ -17,7 +17,7 @@ from .interface import ImporterInterface if TYPE_CHECKING: - from .schema import NodeSchema, RelationshipSchema + from ...schema import NodeSchema, RelationshipSchema class LineDelimitedJSONImporter(ImporterInterface): @@ -163,7 +163,7 @@ async def execute_batches( self, batches: list[InfrahubBatch], progress_bar_message: str = "Executing batches" ) -> Sequence[Any]: if self.console: - task_count = sum((batch.num_tasks for batch in batches)) + task_count = sum(batch.num_tasks for batch in batches) progress = Progress() progress.start() progress_task = progress.add_task(f"{progress_bar_message}...", total=task_count) diff --git a/pyproject.toml b/pyproject.toml index 9915bd59..fc3ba236 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -245,7 +245,6 @@ ignore = [ "B008", # Do not perform function call `typer.Option` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable "B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling "C408", # Unnecessary `dict` call (rewrite as a literal) - "C414", # Unnecessary `list` call within `sorted()` "FURB110", # Replace ternary `if` expression with `or` operator "FURB113", # Use `lines.extend((" " * self.indentation + "}", "}"))` instead of repeatedly calling `lines.append()` "FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups @@ -267,12 +266,10 @@ ignore = [ "PTH109", # `os.getcwd()` should be replaced by `Path.cwd()` "RET504", # Unnecessary assignment to `data` before `return` statement "RUF", # Unused `noqa` directive - "S105", # Possible hardcoded password assigned to: "PASS" "S108", # Probable insecure usage of temporary file or directory "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes "S701", # By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` "SIM102", # Use a single `if` statement instead of nested `if` statements - "SIM103", # Return the condition directly "SIM105", # Use `contextlib.suppress(KeyError)` instead of `try`-`except`-`pass` "SIM108", # Use ternary operator `key_str = f"{value[ALIAS_KEY]}: {key}" if ALIAS_KEY in value and value[ALIAS_KEY] else key` instead of `if`-`else`-block "SIM110", # Use `return any(getattr(item, resource_field) == resource_id for item in getattr(self, RESOURCE_MAP[resource_type]))` instead of `for` loop @@ -282,7 +279,6 @@ ignore = [ "SIM910", # Use `data.get(key)` instead of `data.get(key, None)` "UP007", # Use X | Y for type annotations "UP031", # Use format specifiers instead of percent format - "UP034", # Avoid extraneous parentheses ] @@ -322,10 +318,15 @@ max-complexity = 17 "PLR0904", # Too many public methods ] +"infrahub_sdk/pytest_plugin/models.py" = [ + "S105", # 'PASS' is not a password but a state +] + + "tests/**/*.py" = [ "PLR2004", # Magic value used in comparison "S101", # Use of assert detected - "S106", # Possible hardcoded password assigned to variable + "S105", # Possible hardcoded password assigned to variable "S106", # Possible hardcoded password assigned to argument ################################################################################################## diff --git a/tests/integration/test_object_store.py b/tests/integration/test_object_store.py index 3da9d57f..5296cb97 100644 --- a/tests/integration/test_object_store.py +++ b/tests/integration/test_object_store.py @@ -11,7 +11,7 @@ class TestObjectStore(TestInfrahubApp): async def test_upload_and_get(self, client: InfrahubClient): response = await client.object_store.upload(content=FILE_CONTENT_01) - assert sorted(list(response.keys())) == ["checksum", "identifier"] + assert sorted(response.keys()) == ["checksum", "identifier"] assert response["checksum"] == "aa19b96860ec59a73906dd8660bb3bad" assert response["identifier"]