Skip to content

Commit

Permalink
Merge pull request #955 from projectsyn/fix/mypy-warning
Browse files Browse the repository at this point in the history
Fix mypy error for spurious `return` in `Component.lib_files`
  • Loading branch information
simu authored Apr 29, 2024
2 parents bd4b54c + 7b2584b commit 351fafc
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 @@ -140,15 +140,17 @@ def defaults_file(self) -> P:

@property
def lib_files(self) -> Iterable[P]:
# NOTE(sg): Usage of yield makes the whole function return a generator.
# So if the top-level condition is false, this should immediately raise
# a StopIteration exception. Mypy has started to complain about the
# `return []` that was previously part of this function.
lib_dir = self.target_directory / "lib"
if lib_dir.exists():
for e in lib_dir.iterdir():
# Skip hidden files in lib directory
if not e.name.startswith("."):
yield e

return []

def get_library(self, libname: str) -> Optional[P]:
lib_dir = self.target_directory / "lib"
if not lib_dir.exists():
Expand Down

0 comments on commit 351fafc

Please sign in to comment.