Skip to content

Add ament_lint_auto_py and ament_lint_common_py#569

Open
InvincibleRMC wants to merge 22 commits intoament:rollingfrom
InvincibleRMC:ament_lint_auto-for-python
Open

Add ament_lint_auto_py and ament_lint_common_py#569
InvincibleRMC wants to merge 22 commits intoament:rollingfrom
InvincibleRMC:ament_lint_auto-for-python

Conversation

@InvincibleRMC
Copy link
Copy Markdown
Contributor

@InvincibleRMC InvincibleRMC commented Jan 25, 2026

Description

Adding ament_lint_auto_py and ament_lint_common_py to allow auto linting for ament_python packages. It should have 1 to 1 parity with ament_lint_auto features. Including support for ament_lint_auto_exclude and ament_lint_auto_file_exclude.

Is this user-facing behavior change?

Yes it would simpler running linters in ament_python build packages. Throughout the core sometimes linters get missed. And if we ever wanted to add more in the future [like ament_mypy for typing ;)] being able to use similar logic to ament_lint_auto in CMakeLists.txt would be very useful.

Did you use Generative AI?

Additional Information

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
@InvincibleRMC InvincibleRMC marked this pull request as ready for review January 25, 2026 04:12
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
@peci1
Copy link
Copy Markdown

peci1 commented Jan 25, 2026

I very much like this initiative.

Does it mean that all the copy-pasted lint tests in downstream repos would be replaced just by something like test_ament_lint_auto.py from the readme? Is there no way to do it even without this one (e.g. generate it at build time)?

It's not clear to me why does ament_lint_common_py contain also the C++-only linters like cppcheck. Does it make sense in some scenarios? Or is it just to have 1:1 mapping between cpp and py linters? Regardless of the answer, I think this should be documented in the readme.

Also, setting excludes only via environment variables is insufficient. That's good for local development, but unusable on the buildfarm and in other automated build environments. Or am I missing something?

If specifying the excludes in setup.py is not possible, what about the export section in package.xml? But I don't like this solution either because it would leak implementation details like file names leak into the overall metadata provided by package.xml.

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
@InvincibleRMC
Copy link
Copy Markdown
Contributor Author

InvincibleRMC commented Jan 26, 2026

Do to your questions/feedback I have done some updates.

  1. I was able to remove needing the def test_ament_lint_auto() function from being called downstream now just having ament_lint_auto_py in the package.xml will cause all linters listed in the package.xml to run.
  2. Added a note about keeping parity between ament_lint_common and ament_lint_common_py. I could see a world we remove the C++ lint dependencies but, the initial implementation goal was parity.
  3. For settings I moved from environment variables to pytest variables to be configured in a pytest.ini /pyproject.toml per package.

@InvincibleRMC
Copy link
Copy Markdown
Contributor Author

@fujitatomoya would you mind reviewing this?

Copy link
Copy Markdown

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i got several minor comments only, i would like someone else who is familiar with ament to review this before merge.

Comment thread ament_lint_auto_py/ament_lint_auto_py/pytest_plugin.py Outdated
Comment thread ament_lint_auto_py/doc/index.rst Outdated
Comment thread ament_pep257/ament_pep257/main.py Outdated
Comment thread ament_pycodestyle/ament_pycodestyle/main.py Outdated
Comment thread ament_pyflakes/ament_pyflakes/main.py Outdated
Comment thread ament_lint_auto_py/ament_lint_auto_py/pytest_plugin.py Outdated
Comment thread ament_lint_auto_py/doc/index.rst Outdated
Comment thread ament_lint_auto_py/doc/index.rst Outdated
Comment thread ament_lint_auto_py/doc/index.rst Outdated
Comment thread ament_lint_common_py/doc/index.rst Outdated
InvincibleRMC and others added 12 commits February 6, 2026 16:41
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants