Skip to content

Commit

Permalink
Remove untested branch in alias_directory
Browse files Browse the repository at this point in the history
We simply assert that `apath` is not None to signal to mypy that there's
no possible way that the alias isn't registered on the alias
multi-dependency (and therefore `adep.get_component(alias) will never
return None) when the alias is present in `_aliases`.
  • Loading branch information
simu committed Feb 14, 2025
1 parent 038f688 commit 4d5f0fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions commodore/component/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ def alias_directory(self, alias: str) -> P:
)
adep = self._aliases[alias][2]
apath = adep.get_component(alias)
if not apath:
raise ValueError(f"unknown alias {alias} for component {self.name}")
# Here: if alias is registered in `self._aliases` it must be registered on the
# alias's multi-dependency. The assert makes mypy happy. We disable bandit's
# "assert_used" lint, since we don't rely on this assertion for correctness.
assert apath # nosec B101
return apath / self._aliases[alias][1]

def alias_class_file(self, alias: str) -> P:
Expand Down

0 comments on commit 4d5f0fc

Please sign in to comment.