Skip to content

Commit 03194e1

Browse files
Add support for type stubs (#516)
Signed-off-by: Michael Carlstrom <[email protected]>
1 parent 33cf364 commit 03194e1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

ament_mypy/ament_mypy/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ def _get_files(paths: List[str]) -> List[str]:
226226
for filename in sorted(filenames):
227227
if filename.endswith('.py'):
228228
files.append(os.path.join(dirpath, filename))
229+
elif filename.endswith('.pyi'):
230+
type_stub_path = os.path.join(dirpath, filename)
231+
files.append(type_stub_path)
232+
233+
regular_file_path = type_stub_path.removesuffix('i')
234+
# Use type stub over file
235+
if regular_file_path in files:
236+
files.remove(regular_file_path)
229237
elif os.path.isfile(path):
230238
files.append(path)
231239
return [os.path.normpath(f) for f in files]

0 commit comments

Comments
 (0)