FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-103556: [inspect.Signature] disallow pos-or-kw params without default after pos-only with default by sobolevn · Pull Request #103557 · python/cpython · GitHub

/ cpython Public

gh-103556: [inspect.Signature] disallow pos-or-kw params without default after pos-only with default - #103557

Merged
carljm merged 4 commits into
python:mainfrom
sobolevn:issue-103556
Apr 22, 2023
Merged

gh-103556: [inspect.Signature] disallow pos-or-kw params without default after pos-only with default#103557
carljm merged 4 commits into
python:mainfrom
sobolevn:issue-103556

Conversation

sobolevn commented Apr 15, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

I consider this a bug fix, not a new feature. So, backport to 3.11 should probably be done.

Copy link
Copy Markdown
Member Author

test_nntplib failure seems unrelated, but I cannot re-trigger Azure build.

Comment thread Lib/test/test_inspect.py Outdated

Copy link
Copy Markdown
Member Author

@hauntsaninja if you are interested in this as well after #103554 I would be very grateful :)

carljm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for finding and fixing this!

I think the fix can be even simpler, though; see inline comment.

Comment thread Lib/inspect.py Outdated
Comment on lines +3024 to +3029
if (top_kind != _POSITIONAL_ONLY
and kind != _POSITIONAL_OR_KEYWORD):
# We still have to maintain defaults in cases like
# def some(pod=42, /, pk=1): ...
# Here `pk` must have a default value.
kind_defaults = False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

non-default-after-default is only checked for _POSITIONAL_ONLY and _POSITIONAL_KEYWORD (see line 3032.) So if we want to keep the value of kind_defaults across the transition from PO to POK (which I do agree is correct and matches the parser behavior), then really we always want to keep it, and it is no longer kind_defaults but simply seen_default. So I think we can eliminate all of this, here's the full version I'd recommend (which passes all tests): https://gist.github.com/carljm/6779e601d04e0b1135444b4e0263e281

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, I agree, thank you for the suggestion.

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

Copy link
Copy Markdown

Thanks for making the requested changes!

@carljm: please review the changes made to this pull request.

bedevere-bot requested a review from carljm April 19, 2023 08:40
carljm added the needs backport to 3.11 only security fixes label Apr 22, 2023
carljm merged commit 6b58d41 into python:main Apr 22, 2023

Copy link
Copy Markdown
Contributor

Thanks @sobolevn for the PR, and @carljm for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 22, 2023
…t default after pos-only with default (pythonGH-103557)

(cherry picked from commit 6b58d41)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

Copy link
Copy Markdown

GH-103675 is a backport of this pull request to the 3.11 branch.

bedevere-bot removed the needs backport to 3.11 only security fixes label Apr 22, 2023
carljm pushed a commit that referenced this pull request Apr 22, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL