Added undescore to ignore new pydocstyle item#428
Conversation
Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com>
|
Rolling CI is installing Pydocstyle 6.1.1: |
|
CI: Linux CI is upgrading to 6.2.1 |
ament_pep257/ament_pep257/main.py
Outdated
|
|
||
| files_dict = {} | ||
| for filename, checked_codes, ignore_decorators in files_to_check: | ||
| for filename, checked_codes, ignore_decorators, _ in files_to_check: |
There was a problem hiding this comment.
So this isn't going to work with older pydocstyle, which we still need to support for users who haven't upgraded the pydocstyle yet.
Instead, I think we'll need to first try to unpack 3 values, and if that fails with a ValueError, then try to unpack with 4 values. Alternatively, we could look up the version number of pydocstyle that is currently in use, and choose which one to do based on that (though I think that is a little more brittle).
Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com>
ament_pep257/ament_pep257/main.py
Outdated
| # Unpack 3 values for pydocstyle <= 6.1.1 | ||
| try: | ||
| for filename, checked_codes, ignore_decorators in files_to_check: | ||
| if _filename_in_excludes(filename, excludes): | ||
| continue | ||
| files_dict[filename] = { | ||
| 'select': checked_codes, | ||
| 'ignore_decorators': ignore_decorators, | ||
| } | ||
| # Unpack 4 values since pydocstyle >= 6.2.0 | ||
| except ValueError: | ||
| for filename, checked_codes, ignore_decorators, _ in files_to_check: | ||
| if _filename_in_excludes(filename, excludes): | ||
| continue | ||
| files_dict[filename] = { | ||
| 'select': checked_codes, | ||
| 'ignore_decorators': ignore_decorators, | ||
| } |
There was a problem hiding this comment.
This definitely works, but duplicates the body of the loop.
I actually just learned about a new Python 3 syntax that lets you unpack an optional set of arguments at the end, *_. So I think we can handle returning 3 or 4 tuple items, without duplicating the body of the loop, with:
| # Unpack 3 values for pydocstyle <= 6.1.1 | |
| try: | |
| for filename, checked_codes, ignore_decorators in files_to_check: | |
| if _filename_in_excludes(filename, excludes): | |
| continue | |
| files_dict[filename] = { | |
| 'select': checked_codes, | |
| 'ignore_decorators': ignore_decorators, | |
| } | |
| # Unpack 4 values since pydocstyle >= 6.2.0 | |
| except ValueError: | |
| for filename, checked_codes, ignore_decorators, _ in files_to_check: | |
| if _filename_in_excludes(filename, excludes): | |
| continue | |
| files_dict[filename] = { | |
| 'select': checked_codes, | |
| 'ignore_decorators': ignore_decorators, | |
| } | |
| # Unpack 3 values for pydocstyle <= 6.1.1, and 4 values for pydocstyle >= 6.2.0. | |
| for filename, checked_codes, ignore_decorators, *_ in files_to_check: | |
| if _filename_in_excludes(filename, excludes): | |
| continue | |
| files_dict[filename] = { | |
| 'select': checked_codes, | |
| 'ignore_decorators': ignore_decorators, | |
| } |
Can you give this a try and see if it still solves the problem?
Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com>
Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com>
Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com>
clalancette
left a comment
There was a problem hiding this comment.
Looks good with green CI!
Please make sure to run CI up to some package that uses ament_pep257, as well as on RHEL (to make sure it still works there).
|
This is all green, so merging this in. |
|
@Mergifyio backport humble |
* Added underscore to ignore new item Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com> (cherry picked from commit ae431ed)
✅ Backports have been createdDetails
|
* Added underscore to ignore new item Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com> (cherry picked from commit ae431ed) Signed-off-by: Audrow Nash <audrow@openrobotics.org>
* Added underscore to ignore new item Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com> (cherry picked from commit ae431ed) Signed-off-by: Audrow Nash <audrow@openrobotics.org> Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com> Signed-off-by: Audrow Nash <audrow@openrobotics.org> Co-authored-by: Cristóbal Arroyo <69475004+Crola1702@users.noreply.github.com>
|
@mergify backport foxy |
❌ Command disallowed due to command restrictions in the Mergify configuration.Details
|
|
@Mergifyio backport foxy |
* Added underscore to ignore new item Signed-off-by: Crola1702 <cristobal.arroyo@ekumenlabs.com> (cherry picked from commit ae431ed) # Conflicts: # ament_pep257/ament_pep257/main.py
✅ Backports have been createdDetails
|
|
Could we get a release in foxy so we can get this change please? I believe everyone's foxy CIs for ros2 python packages are failing without this change right now. Thanks! |
FYI: @jacobperron |
|
I'll comment over on the backport PR. |
Signed-off-by: Crola1702 cristobal.arroyo@ekumenlabs.com
Pydocstyle 6.2.0 introduced a new feature where
get_files_to_checkmethod yields 4 items instead of 3.This PR adds and ignores that item, so the tests can run without crashing.