Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
miss-islington merged 5 commits intopython:mainfromAbhigyanBose:fix-issue-91832
Apr 28, 2022

Conversation

@AbhigyanBose
Copy link
Contributor

@AbhigyanBoseAbhigyanBose commentedApr 22, 2022
edited by miss-islington
Loading

Adding 'required' to names in Lib.argparse.Action

gh-91832:
Added 'required' to the listnames inLib.argparse.Action.
Changed constant strings that test the Action object.

Automerge-Triggered-By: GH:merwok

@fatihkabakk
Copy link
Contributor

fatihkabakk commentedApr 22, 2022
edited
Loading

We got the same error, here is my pr#91840.
It's weird that when patchcheck made, it deletes whitespaces, but when not it throws error.
I also mentioned that problem on my comment in#91840 .

@AbhigyanBose
Copy link
ContributorAuthor

Thanks for pointing it out. I just realized the same.

fatihkabakk reacted with thumbs up emoji

@merwokmerwok changed the titlegh-91832: Adding 'required' to names in Lib.argparse.Actiongh-91832: Adding 'required' to names in argparse.ActionApr 25, 2022
Copy link
Member

@merwokmerwokApr 25, 2022
edited
Loading

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.

Suggested change
Added 'required' to names list inLib.argparse.Action.
Added 'required' to names list in argparse.Action.

Also mentioningparameters may be clearer thannames

Copy link
ContributorAuthor

@AbhigyanBoseAbhigyanBoseApr 25, 2022
edited
Loading

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 elementrequired to the listnames in argparse.Action._get_kwargs"

Copy link
Member

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 usesnames, it is not meaninfgul on its own when read by people in the NEWS.

Copy link
ContributorAuthor

@AbhigyanBoseAbhigyanBoseApr 25, 2022
edited
Loading

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 inargparse.Action.

Copy link
Member

@merwokmerwokApr 25, 2022
edited
Loading

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
🙂

Copy link
ContributorAuthor

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.

Copy link
Member

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)

@merwokmerwok changed the titlegh-91832: Adding 'required' to names in argparse.Actiongh-91832: Add 'required' attr to argparse.Action reprApr 25, 2022
@terryjreedy
Copy link
Member

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.

@AbhigyanBose
Copy link
ContributorAuthor

@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 runmake patchcheck before I submit.

I could also create a separate PR to add '\n' to that test case.

@terryjreedy
Copy link
Member

A separate PR would be OK. Azure Pipelines passing is not required but its failure from patchcheck failing is a nuisance.

@terryjreedy
Copy link
Member

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.)

@merwok
Copy link
Member

This format spec does funky alignment:

action_header='%*s%-*s '%tup

@AbhigyanBose
Copy link
ContributorAuthor

AbhigyanBose commentedApr 27, 2022
edited
Loading

@merwok and@terryjreedy

I created a newissue for this. I also proposed the solution I thought to be the simplest there.

@AbhigyanBose
Copy link
ContributorAuthor

#91984 has been resolved, thusmake patchcheck is successful. Is there any other change required in this PR ?

Copy link
Member

@merwokmerwok left a 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 therequired attribute is present in these versions too)

…Li65.rstCo-authored-by: Éric <merwok@netwok.org>
@AbhigyanBose
Copy link
ContributorAuthor

Yeah. Seems like backports to 3.10 and 3.9 are necessary.(required is absent in both versions)

@miss-islington
Copy link
Contributor

@AbhigyanBose: Status check is done, and it's a success ✅ .

@miss-islingtonmiss-islington merged commit4ed3900 intopython:mainApr 28, 2022
@miss-islington
Copy link
Contributor

Thanks@AbhigyanBose for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-92021 is a backport of this pull request to the3.10 branch.

@bedevere-bot
Copy link

GH-92022 is a backport of this pull request to the3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestApr 28, 2022
…-91841)GH- Adding 'required' to names in Lib.argparse.Actionpythongh-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 commit4ed3900)Co-authored-by: Abhigyan Bose <abhigyandeepbose@gmail.com>
miss-islington added a commit that referenced this pull requestApr 28, 2022
GH- Adding 'required' to names in Lib.argparse.Actiongh-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 commit4ed3900)Co-authored-by: Abhigyan Bose <abhigyandeepbose@gmail.com>
miss-islington added a commit that referenced this pull requestApr 28, 2022
GH- Adding 'required' to names in Lib.argparse.Actiongh-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 commit4ed3900)Co-authored-by: Abhigyan Bose <abhigyandeepbose@gmail.com>
hello-adam pushed a commit to hello-adam/cpython that referenced this pull requestJun 2, 2022
…-91841)GH- Adding 'required' to names in Lib.argparse.Actionpythongh-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 commit4ed3900)Co-authored-by: Abhigyan Bose <abhigyandeepbose@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@merwokmerwokmerwok approved these changes

Assignees

No one assigned

Labels

stdlibStandard Library Python modules in the Lib/ directory

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@AbhigyanBose@fatihkabakk@terryjreedy@merwok@miss-islington@bedevere-bot@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp