-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-91832: Add 'required' attr to argparse.Action repr #91841
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
Conversation
Thanks for pointing it out. I just realized the same. |
@@ -0,0 +1 @@ | |||
Added 'required' to names list in Lib.argparse.Action. |
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.
Python stdlib doesn’t use a root package name, Lib is just a source directory.
Added 'required' to names list in Lib.argparse.Action. | |
Added 'required' to names list in argparse.Action. |
Also mentioning parameters
may be clearer than names
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.
names
is the name of the list in Action class that we are adding the element to. I should've put it in a code block.
How does this look ?
"Added an element required
to the list names
in argparse.Action._get_kwargs"
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.
Same thing. My point is that it does not matter that a line in the code uses names
, it is not meaninfgul on its own when read by people in the NEWS.
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.
How does this sound then:
Added a parameter "required" to the list returned by _get_kwargs
in argparse.Action
.
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.
The bug really is: required is missing from repr output
So this fix is doing: Add 'required' attr to argparse.Action repr
🙂
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.
Ahhh..... Sorry, I'm still new here, and trying to get to know things. Thanks for taking the time to help me understand.
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.
No worry! There is info in the devguide: https://devguide.python.org/pullrequest/
(for future PRs, please don’t force push, it makes reviews harder)
daf292a
to
94d0853
Compare
As suggested by Ronald Oussoren on core mentorship, changing a line like ' x ' to ' x \n' should solve the patchcheck failure. In a future issue, parser.format_help might be modified to not format with trailing whitespace. I doubt that it is really needed. Sidenote: I am not sure what you did, but force-pushing is rarely needed when revising PRs and sometimes messes them up. |
@terryjreedy Got it. I just wasn't sure if I should change an unrelated test case's content in this particular PR. If that's what you and @merwok recommend I'll add in '\n' and then run I could also create a separate PR to add '\n' to that test case. |
A separate PR would be OK. Azure Pipelines passing is not required but its failure from patchcheck failing is a nuisance. |
I think Zachary Ware's suggestion of '\x20' might be even better. (How to fix argparse is not obvious. It uses %-formatting and I check all %s and no of format string I looked at had trailing spaces of format character that would produce such.) |
This format spec does funky alignment: Line 521 in 94d0853
|
@merwok and @terryjreedy I created a new issue for this. I also proposed the solution I thought to be the simplest there. |
#91984 has been resolved, thus |
Misc/NEWS.d/next/Library/2022-04-23-03-24-00.gh-issue-91832.TyLi65.rst
Outdated
Show resolved
Hide resolved
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 the PR!
Minor change in news entry then this is good to go.
Can you check if backports to 3.10 and 3.9 are needed? (if the required
attribute is present in these versions too)
…Li65.rst Co-authored-by: Éric <[email protected]>
Yeah. Seems like backports to 3.10 and 3.9 are necessary.( |
@AbhigyanBose: Status check is done, and it's a success ✅ . |
Thanks @AbhigyanBose for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
GH-92021 is a backport of this pull request to the 3.10 branch. |
GH-92022 is a backport of this pull request to the 3.9 branch. |
…-91841) GH- Adding 'required' to names in Lib.argparse.Action pythongh-91832: Added 'required' to the list `names` in `Lib.argparse.Action`. Changed constant strings that test the Action object. Automerge-Triggered-By: GH:merwok (cherry picked from commit 4ed3900) Co-authored-by: Abhigyan Bose <[email protected]>
GH- Adding 'required' to names in Lib.argparse.Action gh-91832: Added 'required' to the list `names` in `Lib.argparse.Action`. Changed constant strings that test the Action object. Automerge-Triggered-By: GH:merwok (cherry picked from commit 4ed3900) Co-authored-by: Abhigyan Bose <[email protected]>
GH- Adding 'required' to names in Lib.argparse.Action gh-91832: Added 'required' to the list `names` in `Lib.argparse.Action`. Changed constant strings that test the Action object. Automerge-Triggered-By: GH:merwok (cherry picked from commit 4ed3900) Co-authored-by: Abhigyan Bose <[email protected]>
…-91841) GH- Adding 'required' to names in Lib.argparse.Action pythongh-91832: Added 'required' to the list `names` in `Lib.argparse.Action`. Changed constant strings that test the Action object. Automerge-Triggered-By: GH:merwok (cherry picked from commit 4ed3900) Co-authored-by: Abhigyan Bose <[email protected]>
Adding 'required' to names in Lib.argparse.Action
gh-91832:
Added 'required' to the list
names
inLib.argparse.Action
.Changed constant strings that test the Action object.
Automerge-Triggered-By: GH:merwok