-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
@@ -187,7 +187,7 @@ def generate_pep257_report(paths, excludes, ignore, select, convention, add_igno | |||
report = [] | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 created
|
* 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.
|
@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 created
|
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_check
method yields 4 items instead of 3.This PR adds and ignores that item, so the tests can run without crashing.