Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate ruff RET rules - WIP #5544

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/infrahub/core/node/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ async def get_path_value(self, db: InfrahubDatabase, path: str) -> str:
attr = getattr(node, schema_path.attribute_schema.name)
return getattr(attr, schema_path.attribute_property_name)

raise ValueError(f"Unable to retrieve the value of path {path!r} on {self.get_kind()!r}")

def get_labels(self) -> list[str]:
"""Return the labels for this object, composed of the kind
and the list of Generic this object is inheriting from."""
Expand Down
3 changes: 2 additions & 1 deletion backend/infrahub/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ async def __aexit__(
traceback: Optional[TracebackType],
):
if self._mode == InfrahubDatabaseMode.SESSION:
return await self._session.close()
await self._session.close()
return

if self._mode == InfrahubDatabaseMode.TRANSACTION:
if exc_type is not None:
Expand Down
6 changes: 4 additions & 2 deletions backend/tests/benchmark/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def _wrapper(func, *args, **kwargs):
@benchmark
def _():
return event_loop.run_until_complete(func(*args, **kwargs))
else:
return benchmark(func, *args, **kwargs)

return _

return benchmark(func, *args, **kwargs)

return _wrapper
2 changes: 2 additions & 0 deletions backend/tests/unit/core/schema_manager/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def _get_schema_by_kind(full_schema, kind):
if schema_kind == kind:
return schema_dict

raise ValueError(f"Schema kind '{kind}' not found in the provided schema.")


@pytest.fixture
async def animal_person_schema_dict() -> dict:
Expand Down
2 changes: 2 additions & 0 deletions backend/tests/unit/core/test_relationship_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ def get_active_path_and_rel(all_paths, previous_rel: str):
if "Relationship" in node.labels and node.get("uuid") != previous_rel:
return path, node

raise ValueError("No active path found")

active_path, latest_rel_node = get_active_path_and_rel(all_paths=paths, previous_rel=rel_node.get("uuid"))

rel_data = RelationshipPeerData(
Expand Down
2 changes: 2 additions & 0 deletions backend/tests/unit/graphql/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def default_branch(self) -> Branch:
if self._default_branch:
return self._default_branch

raise NotImplementedError()


@pytest.fixture(scope="module")
def permissions_helper() -> PermissionsHelper:
Expand Down
2 changes: 1 addition & 1 deletion models/infrastructure_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ async def run(
config.load_config(profile, num_sites, num_device_per_site, bool_has_bgp_mesh, bool_has_branch)
except ConfigError as ex:
log.fatal(ex)
return False # FIXME: What should I return here for the script to fail properly
raise

# Print config
log.info(f"Loading data with {config}")
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ ignore = [
"PLR6301", # Method could be a function, class method, or static method
"PLW0603", # Using the global statement to update `SETTINGS` is discouraged
"PLW1508", # Invalid type for environment variable default; expected `str` or `None`
"RET503", # Missing explicit `return` at the end of function able to return non-`None` value
"RET504", # Unnecessary assignment before `return` statement
"RUF005", # Consider `[*list(peers.values()), rfc5735]` instead of concatenation
"RUF006", # Store a reference to the return value of `asyncio.create_task`
Expand Down
Loading