ament / ament_lint

Apache License 2.0
38 stars 107 forks source link

[backport humble] Fix compatibility with flake8 version 5 (#387, #410) #451

Closed emersonknapp closed 1 year ago

emersonknapp commented 1 year ago

This is a combined backport of #387 and #410 to Humble.

When building on Ubuntu 20.04 Focal (Tier 3 support) and following the instructions in https://docs.ros.org/en/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-development-tools-and-ros-tools for that platform, flake8 is installed via pip and so is installed at the newer version 5. ament_lint then fails to run with:

/opt/ros/humble/install/lib/python3.8/site-packages/ament_flake8/main.py:150: in get_flake8_style_guide
    config_finder = config.ConfigFileFinder(
E   AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder'

387 original text

This PR fixes https://github.com/ament/ament_lint/issues/382 by explicitly adding any exclude args in the flake8 config file (normally configuration/ament_flake8.ini) to the exclude arglist.

Notably, this uses the same parsing logic that the version of flake8 ROS is using on focal and jammy (3.9.7 and 4.0.0). I tried to account for differences in the parsing logic between 3.9.7 and 4.0.0 with a try except clause.

410 original text

The ConfigFileFinder class no longer exists in flake8 version 5. The get_style_guide() code has been updated from the latest api.legacy.get_style_guide() in flake8.

emersonknapp commented 1 year ago

Rebased and re-pushed, branch produced by

git cherry-pick 66c76cc  # 387
git cherry-pick 6adf864  # 410
git rebase --signoff origin/humble
emersonknapp commented 1 year ago

Pulls: ament/ament_lint#451 Gist: https://gist.githubusercontent.com/emersonknapp/004f93b823abd35d251b4153e4cb8022/raw/891034bcc1a07396dbd14a76ccbbfd1f0e56058e/ros2.repos BUILD args: TEST args: ROS Distro: rolling Job: ci_launcher ci_launcher ran: https://ci.ros2.org/job/ci_launcher/12671

emersonknapp commented 1 year ago

@clalancette merge please!