Skip to content

ament_mypy: Exclude does not work as described and file discovery handling differs to mypy #519

@Flova

Description

@Flova

Currently, ament_mypy passes all files explicitly to mypy. There are a few issues with this approach.

First of all, there was #516 until recently (it is still present in jazzy etc.). The logic from #516 is already present in mypy if we pass it a directory, but ament_mypy passes all files individually, because some might be in a folder that is flagged with AMENT_IGNORE and need to be removed. Adding all files individually also disables the exclude feature in the mypy.ini. This is especially relevant since the ament_mypy exclude feature does not really work. Contrary to its help page, only whole directories can be excluded.

My suggestion would be to just pass the given path(s) to mypy without extracting any filenames. The AMENT_IGNORE can be handled by appending these directories to the native exclude parameter of mypy. Similarly, I would just pass the exclude parameter of ament_mypy through to mypy.

This would enable the usage of excludes in the .ini, excludes of files, the removal of the stub priority logic and filename discovery. In the end it is very confusing if e.g. the exclude doesn't work like it's described in the mypy docs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions