Skip to content
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

Merged
merged 5 commits into from
Jan 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions ament_pep257/ament_pep257/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,24 @@ def generate_pep257_report(paths, excludes, ignore, select, convention, add_igno
report = []

files_dict = {}
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
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,
}
Copy link
Contributor

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:

Suggested change
# 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?


for filename in sorted(files_dict.keys()):
print('checking', filename)
Expand Down