-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[symilar] Migrate from getopt to argparse #9731
[symilar] Migrate from getopt to argparse #9731
Conversation
7e17446
to
8e26d68
Compare
8e26d68
to
44e41d7
Compare
This comment has been minimized.
This comment has been minimized.
Thanks for the review @rogersheu |
This comment has been minimized.
This comment has been minimized.
7f40854
to
6d8bd0b
Compare
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #9731 +/- ##
==========================================
- Coverage 95.80% 95.80% -0.01%
==========================================
Files 174 174
Lines 18944 18918 -26
==========================================
- Hits 18149 18124 -25
+ Misses 795 794 -1
|
This comment has been minimized.
This comment has been minimized.
4bf4eeb
to
689e144
Compare
This comment has been minimized.
This comment has been minimized.
assert ex.value.code == 0 | ||
assert "similar lines in" in output.getvalue() | ||
|
||
|
||
def test_bad_short_form_option() -> None: | ||
def test_bad_short_form_option(capsys: CaptureFixture) -> None: |
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 could be out of scope of this PR, but could it be helpful to add a couple more unit tests?
--i
could be useful because it's ambiguous andargparse
allows abbreviation (allow_abbrev
defaults toTrue
)- I also hope a user wouldn't fall into this trap, but it might be relevant to have a test for if a user provides an argument accompaniment to one of the boolean flags (i.e.,
--ignore-comments 1
as you mentioned this in the fragments).
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.
All of those test cases are going to fail with an elegant argparse message. We had a lot of unit tests because we were using getopt and doing too much ourselves (no other choices at time of implementation, as argparse was not builtin yet). I added test previously to check that I wasn't changing the behavior with the migration. I don't know if we should remove tests because we trust argparse now, maybe later (?)
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. Makes sense! Yeah, seeing as a lot of this error handling gets offloaded to argparse
, I think it sounds like it would make sense to remove the tests when ready.
04c34f8
to
757d123
Compare
Thank you for the review @rogersheu, appreciated ! |
pylint/checkers/symilar.py
Outdated
parser.add_argument("files", nargs="+") | ||
parser.add_argument( | ||
"-d", "--duplicates", type=int, default=DEFAULT_MIN_SIMILARITY_LINE | ||
) | ||
parser.add_argument("-i", "--ignore-comments", action="store_true") | ||
parser.add_argument("--ignore-docstrings", action="store_true") | ||
parser.add_argument("--ignore-imports", action="store_true") | ||
parser.add_argument("--ignore-signatures", action="store_true") |
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.
nit: Not sure under what circumstances users might end up seeing the parser's "usage" explanation, but if they might, help
statements might be helpful here.
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.
Nice catch !
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.
Left a tiny comment about help statements, but if the help for Run
won't be seen, it's not necessary.
This comment has been minimized.
This comment has been minimized.
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit ed1b787 |
This reverts commit 23de2d5.
Thank you again for the troubleshooting of the stupid bug I had, and the reviews @rogersheu |
Type of Changes
Description
Follow-up to #9709, had to open a new PR because it's impossible to change the target branch in #9710 to reopen.