test(integration): lint the Python in ros2_medkit_integration_tests - #598
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes the linting gap in ros2_medkit_integration_tests by registering a Python linter test (flake8) so the package is covered by colcon test --ctest-args -L linter, aligning CI lint behavior with the pre-commit hooks.
Changes:
- Register
ament_cmake_flake8+ament_flake8()underif(BUILD_TESTING)for the integration tests package. - Add the required
ament_cmake_flake8test dependency inpackage.xml. - Apply mechanical quote-style adjustments in a small set of Python tests to satisfy the configured flake8 rules.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/ros2_medkit_integration_tests/CMakeLists.txt | Adds ament_cmake_flake8 discovery and registers ament_flake8() in the BUILD_TESTING block. |
| src/ros2_medkit_integration_tests/package.xml | Adds ament_cmake_flake8 as a test dependency so the linter test is available in CI. |
| src/ros2_medkit_integration_tests/test/features/test_logging_api.test.py | Quote-style adjustments in f-strings to satisfy flake8. |
| src/ros2_medkit_integration_tests/test/features/test_discovery_namespace_filter.test.py | Quote-style adjustments in assertion message. |
| src/ros2_medkit_integration_tests/test/features/test_discovery_legacy_mode.test.py | Quote-style adjustments in assertion messages (including multi-part f-string). |
| src/ros2_medkit_integration_tests/test/features/test_discovery_layer_policies.test.py | Quote-style adjustments in assertion messages. |
| src/ros2_medkit_integration_tests/test/features/test_discovery_gap_fill.test.py | Quote-style adjustments in assertion messages. |
| src/ros2_medkit_integration_tests/test/features/test_daisy_chain_aggregation.test.py | Switches f-string triple quotes to avoid quote-rule violations while preserving the literal content. |
| src/ros2_medkit_integration_tests/test/docker/introspection/test_systemd_introspection.py | Quote-style adjustments across decorators, requests, and asserts. |
| src/ros2_medkit_integration_tests/test/docker/introspection/test_container_introspection.py | Quote-style adjustments across decorators, requests, and asserts. |
bburda
force-pushed
the
fix/lint-integration-tests
branch
from
August 6, 2026 14:59
23b949a to
b667e4c
Compare
mfaferek93
reviewed
Aug 6, 2026
mfaferek93
reviewed
Aug 6, 2026
bburda
force-pushed
the
fix/lint-integration-tests
branch
from
August 6, 2026 19:43
a7b1734 to
362b200
Compare
The package registered no linter, so its 92 Python files sat outside `colcon test -L linter` and the documented lint command reported success without checking any of them. The pre-commit hooks did check them, which made the gap show up as a push rejected after a clean local lint run. Register flake8 and correct the quote style it reports. The rewrite is mechanical: every touched file parses to an identical AST. ament_pep257 belongs here too - ros2_medkit_graph_watchdog is the only package in the tree that skips both flake8 and pep257 - but this package drifted while unchecked and 559 docstrings put the summary on the opening line. That is its own change. Closes #596
The package registers no linter, so flake8 never saw this file and it landed with its import groups out of order: a third-party import placed after requests, and a stdlib import in its own trailing group. Only the order changes. The import set is identical and the AST outside the import statements compares equal to the previous version.
ament_flake8() without CONFIG_FILE reads the ini bundled inside the ament_flake8 package, so the repository .flake8 had no effect here. The two carried the same extend-ignore list by hand and nothing would have reported it if they diverged. The call now points at the repository file. Both currently produce the same verdict, so no finding changes; what changes is that an edit to .flake8 now reaches this gate.
scripts/ and docs/ sit outside every ROS package, so no ament_flake8 run has ever checked them, and the pre-commit hook lacks the quote, builtins and comprehensions plugins that would have. Both files had drifted from the style the rest of the tree is held to: 198 double-quoted literals and 4 dict() calls in place of literals. Quotes were converted with a tokenizer pass that skips any literal containing a quote or a backslash, so no escaping decision is ever made automatically. That left 36 literals to convert by hand: 10 f-strings, which the tokenizer does not expose as plain STRING tokens, and 26 non-f-string literals the tokenizer skipped for containing a backslash (raw regex patterns and '\n' separators) but which contain no quote, so no escaping decision was needed for them either. generate_verification.py parses to an identical AST before and after. conf.py parses to an identical AST except at the four dict() call sites, now written as literals; their keys and values were verified equal by direct comparison, not by AST equality. conf.py was checked by building the documentation, and generate_verification.py by running it.
The hook installed blind-except, class-newline, docstrings and import-order. ament_flake8 depends on builtins, comprehensions, docstrings, import-order and quotes. So Q, A and C4 ran in quality.yml and nowhere locally, and a file could pass every hook and then turn CI red. The hook now installs all five ament_flake8 has, keeping the two it already had on top. That makes it a superset rather than a match: blind-except and class-newline stay local-only because ament_flake8 comments both out of its package.xml. The comment in the integration tests CMakeLists said the rule sets matched; it now says what is actually true.
…ndings in e2e tests These four e2e test files carried findings that predate this branch. Running flake8 with only D, I and E selected against the files as they stood at 930ca5d reproduces the same 15 findings fixed here: 4 D205, 1 D209, 4 D400, 2 E501 and 4 I100. Selecting Q, A and C4 against the same content finds nothing, so none of this is fallout from adding flake8-builtins, flake8-comprehensions or flake8-quotes to the pre-commit hook in the previous commit. D comes from flake8-docstrings and I from flake8-import-order, both already installed in the hook before that change. pre-commit only runs flake8 against files that are part of a commit, so nothing had exercised these four files since those two plugins were added. `pre-commit run flake8 --all-files` is what finally scanned them and turned up the findings fixed here: module and class docstring summaries reshaped into a single, period-terminated sentence on the opening line with a blank line before the description; the harness import in each file annotated with `# noqa: E402, I100` and the same explanation already used in test_param_drift_e2e.test.py, since the sys.path.insert one line above makes the import order this checker wants impossible; and two lines wrapped under the 99 column limit.
The ros2_medkit_integration_tests CMakeLists comment counted 563 docstrings that put their summary on the opening line and claimed every other package in the tree runs ament_pep257. The real count is 559, and ros2_medkit_graph_watchdog is the one package that still excludes both flake8 and pep257 for its Python files. The same comment also claimed the pre-commit hook installing the plugins ament_flake8 depends on means nothing the gate rejects can pass the hook. CI installs those plugins from apt while the hook's additional_dependencies are unpinned and resolve from PyPI, so the comment now states plugin coverage rather than an outcome guarantee. The pre-commit config comment had a matching grammar slip and did not say that the hook only checks the files a commit touches, unlike quality.yml, which lints the whole package. The ros2_medkit_graph_watchdog CMakeLists comment said no package in the workspace lints Python. ros2_medkit_integration_tests now does, so the comment is rewritten to say this package is the last one still excluding those checks.
bburda
force-pushed
the
fix/lint-integration-tests
branch
from
August 6, 2026 19:54
362b200 to
7923285
Compare
Removes ament_cmake_flake8 from AMENT_LINT_AUTO_EXCLUDE so graph_watchdog's e2e test scripts run through the same check as the rest of the tree; only pep257 stays excluded, deferred with the docstring backlog documented in ros2_medkit_integration_tests. Also skips ament_cmake_flake8 in the Dockerfile's rosdep key list, since the image build runs with BUILD_TESTING=OFF and never installs or uses the linter.
mfaferek93
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
ros2_medkit_integration_testshas 92 Python files and registered no linter. Itsif(BUILD_TESTING)block set up the launch tests but never calledament_lint_auto_find_test_dependencies(), and the package had no flake8 test dependency.So
./scripts/test.sh lint, andcolcon test --ctest-args -L linterbehind it, reported success while the largest Python package in the repository was not checked. The pre-commit hooks did check these files, so problems were still caught, but only at commit or push time. That is confusing: you run the documented lint command, it passes, and then the push is rejected.This registers flake8 for the package and corrects the quote style it reports. Four more gaps in the same area are fixed here too.
The first one is the flake8 configuration.
ament_flake8()withoutCONFIG_FILEreads the ini file bundled inside the installedament_flake8package. The repository.flake8was never used here. The two files held the same settings, but they were kept in sync by hand, and nothing would report a difference. The call now points at the repository file.The second one is the plugin set.
ament_flake8depends on flake8-builtins, flake8-comprehensions, flake8-docstrings, flake8-import-order and flake8-quotes. The pre-commit hook installed blind-except, class-newline, docstrings and import-order. So the Q, A and C4 checks ran in CI and did not run locally. A file could pass every hook and then makequality.ymlred. The hook now installs all five plugins thatament_flake8uses, and keeps the two it already had. The hook is therefore a superset of CI, not an exact match. blind-except and class-newline stay local only, becauseament_flake8does not use them.The third one is the Python that is not part of any ROS package.
scripts/generate_verification.pyanddocs/conf.pywere never checked byament_flake8, because no package owns them. They had 198 double-quoted strings and 4dict()calls that should be literals. The quotes were converted with a tokenizer pass. That pass skips any string that contains a quote, so it never has to decide about escaping. The remaining strings were converted by hand.The fourth one is
ros2_medkit_graph_watchdog. It excluded both flake8 and pep257. Its 6 Python files are already clean under flake8, so the exclusion is removed and the package runs flake8 now. pep257 stays off there for the same reason as inros2_medkit_integration_tests: 559 multi-line docstrings put the summary on the opening line, and fixing them is a separate change with its own issue. Running the hook over all files also reported 15 findings in four graph_watchdog e2e tests (4 D205, 1 D209, 4 D400, 2 E501, 4 I100). These do not come from the plugins added here. They were already there before this branch. They are fixed in a separate commit.Issue
Type
Testing
colcon test --packages-select ros2_medkit_integration_tests --ctest-args -L linternow runs a flake8 test and it passes. Before this change the same command ran none.In
ros2_medkit_graph_watchdog,ctest -N -L linterlists flake8 and does not list pep257.pre-commit run flake8 --all-filespasses on the whole repository.For the quote conversion, every changed file was compared with
ast.dump(ast.parse(...))against its previous version.scripts/generate_verification.pyis identical.docs/conf.pyis identical except at the fourdict()places, where a call node becomes a dict node. The keys and values there were compared one by one.conf.pywas also checked by building the documentation, andgenerate_verification.pyby running it.All changed Python files compile under Python 3.11. So nothing here needs the f-string syntax that only Python 3.12 accepts.
Checklist
No behaviour change and no public API change. The CMake comment says why only flake8 is registered for now, and why
ament_lint_commonis not used here: it would also apply the C++ style checks to the demo nodes in this package, which is a separate decision.