-
Notifications
You must be signed in to change notification settings - Fork 110
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
Expand ignores to pep257 definition. #241
Conversation
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.
I see the interest in changing ament_pep257
to actually comply with PEP257, but what's the harm in the former performing a few more checks?
At least in the case of D212 and D213, pep257 allows for docstrings to start either on the same line as the opening quotes or the next line. These error checks pigeonhole the user into strictly one style or the other, causing valid strings under pep257 to fail. The user should have to explicitly enable one to check for consistency if they care about that. The remainder are fine to keep, though some are redundant. |
ament_pep257/ament_pep257/main.py
Outdated
elif args.allow_undocumented is None: | ||
warnings.warn('Argument "--allow-undocumented" will be required in a future version. ' | ||
'Defaulting to --allow-undocumented=True') | ||
args.ignore.append('D1') |
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.
Thanks for keeping backward compatibility.
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 is great as a long-term goal, but I do not know if there'll be resources to document all core ROS 2 python
code in the near future. Meaning, the warning may result in unwarranted noise.
0b9856b
to
9917409
Compare
ament_pep257/ament_pep257/main.py
Outdated
elif args.allow_undocumented is None: | ||
warnings.warn('Argument "--allow-undocumented" will be required in a future version. ' | ||
'Defaulting to --allow-undocumented=True') | ||
args.ignore.append('D1') |
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 is great as a long-term goal, but I do not know if there'll be resources to document all core ROS 2 python
code in the near future. Meaning, the warning may result in unwarranted noise.
@@ -45,11 +46,20 @@ def main(argv=sys.argv[1:]): | |||
parser.add_argument( | |||
'--ignore', | |||
nargs='*', | |||
default=[ | |||
'D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D106', 'D107', | |||
'D203', 'D212', 'D404', |
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.
These error checks pigeonhole the user into strictly one style or the other, causing valid strings under pep257 to fail.
I understand, but changing this tool defaults will affect the style that is enforced throughout ROS 2 core packages. D212 was intentionally introduced by #61, it wasn't an omission. @Karsten1987 do you recall the rationale behind that patch?
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.
Ultimately, an external user could relax constraints (i.e. ignore both D212 and D213) without us changing the defaults.
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.
Restored the default error checking behavior in e09982a.
Note that some merging code is necessary to duplicate the old behavior
ament_lint/ament_pep257/ament_pep257/main.py
Lines 76 to 82 in e09982a
default_ignore = set(['D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D106', 'D107']) | |
if 'D1' in args.select: | |
default_ignore = set([]) | |
default_ignore -= set(args.select) | |
args.ignore += default_ignore | |
args.select.append('D213') |
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.
Hmm, instead of making assumptions on what the default ignored error codes are and forcing others to set a baseline, I'd much rather replicate pydocstyle
interface i.e. to have --ignore
, --select
, --add-ignore
, and --add-select
, and keep the default --ignore
list as it used to be. Thoughts?
@Arnatious friendly ping. |
9917409
to
3ad9a2e
Compare
@Arnatious @hidmic friendly ping :) It looks like @Arnatious has made changes since your review, and now there's a merge conflict with this PR. @Arnatious mind fixing the merge conflict? |
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.com>
e09982a
to
555b41d
Compare
b75c8db
to
b307f10
Compare
Signed-off-by: Ted Kern <ted.kern@canonical.com>
b307f10
to
c59cc3d
Compare
Signed-off-by: Ted Kern <ted.kern@canonical.com>
9150dd4
to
600f539
Compare
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.
LGTM but for a few comments
ament_pep257/ament_pep257/main.py
Outdated
'--convention', | ||
choices=pydocstyle.conventions, | ||
default='ament', | ||
help=f'Choose a preset list of error codes. Valid options are {pydocstyle.conventions}' |
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.
@Arnatious will ament
show up in pydocstyle.conventions
? I'd expect ament_pep257 --convention=ament
not to fail, even if redundant.
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.
a4d6399 added logic to populate/allow "ament" as an option
ament_pep257/ament_pep257/main.py
Outdated
'D107', | ||
'D203', | ||
'D212', | ||
'D404']) |
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.
@Arnatious uh, is flake8
happy with this?
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.
It was, but I ran it through black in 6a645fc and it looks better now
Signed-off-by: Ted Kern <ted.kern@canonical.com>
Signed-off-by: Ted Kern <ted.kern@canonical.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.
LGTM
@Arnatious mind to fix DCO? I'll run CI afterwards. |
Signed-off-by: Ted Kern <ted.kern@canonical.com>
6a645fc
to
f5404f1
Compare
@hidmic fixed |
How can a user get the information what codes are being ignored (e.g. for the |
@dirk-thomas that's a good question. --convention is taken right from ament is pep257, with the addition of ignoring "D1" (undocumented) and for some unexplained reason enforcing D213. Would a readme explaining the options coming from pydocstyle/linking to the pydocstyle style docs as appropriate be desired? |
Before this patch a user could call |
Signed-off-by: Ted Kern <ted.kern@canonical.com>
@dirk-thomas added help text in e96b4ab Resulting output is
|
Thanks, LGTM. |
Alright, CI's green, PR's approved. Going in. Thanks for your patience @Arnatious ! |
This PR seems to be causing runtime errors in our builds - e.g. https://github.com/ros-tooling/action-ros-ci/runs/870259711?check_suite_focus=true
I'm not sure exactly what this issue is, but the |
Followup - the My recommendation is to revert this PR and then make sure we have a Python3.7-compliant build before merging it again. |
Indeed, looks like extend is new of as 3.8 (https://docs.python.org/3/library/argparse.html). @Arnatious mind fixing that? |
The behavior of extend isn't actually necessary, so I removed it in 7623ada, my bad @emersonknapp |
Thanks for the fix - is that commit in a followup PR? |
Yes, #262 |
Fixes #240 by using
--add-ignore
to allow user to expand pep257 ignores, and add error codes to check.-add-select
functionality added via the--select
flag, allowing full customization of error codes to checkSigned-off-by: Ted Kern ted.kern@canonical.com