Skip to content

Commit

Permalink
Add support for type stubs (#516)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carlstrom <[email protected]>
  • Loading branch information
InvincibleRMC authored Jan 24, 2025
1 parent 33cf364 commit 03194e1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ament_mypy/ament_mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ def _get_files(paths: List[str]) -> List[str]:
for filename in sorted(filenames):
if filename.endswith('.py'):
files.append(os.path.join(dirpath, filename))
elif filename.endswith('.pyi'):
type_stub_path = os.path.join(dirpath, filename)
files.append(type_stub_path)

regular_file_path = type_stub_path.removesuffix('i')
# Use type stub over file
if regular_file_path in files:
files.remove(regular_file_path)
elif os.path.isfile(path):
files.append(path)
return [os.path.normpath(f) for f in files]
Expand Down

0 comments on commit 03194e1

Please sign in to comment.