GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-103406: Modernize pos-only arguments usage in `test_signature` by sobolevn · Pull Request #103407 · python/cpython

Conversation

@sobolevn

@sobolevn sobolevn commented Apr 10, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

We can be sure that these .__signature__ manipulations are safe to removed, because:

  1. Tests do pass now
  2. Places where .replace calls are required by the test logic (for example, when testing Signature and Parameter subclasses or invalid states) are not touched
  3. .__signature__ change is tested here:

    cpython/Lib/test/test_inspect.py

    Lines 1045 to 1051 in ecad802

    def test_getfullargspec_signature_attr(self):
    def test():
    pass
    spam_param = inspect.Parameter('spam', inspect.Parameter.POSITIONAL_ONLY)
    test.__signature__ = inspect.Signature(parameters=(spam_param,))
    self.assertFullArgSpecEquals(test, ['spam'])

Now, / is used where it must be used.

  • Issue: Modernize test_inspect by adding real pos-only parameters #103406

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sobolevn
pythongh-103406: Modernize pos-only arguments usage in test_signature
f06ee15
@bedevere-bot bedevere-bot added the tests Tests in the Lib/test dir label Apr 10, 2023
@bedevere-bot bedevere-bot mentioned this pull request Apr 10, 2023
Modernize test_inspect by adding real pos-only parameters #103406
Closed
@bedevere-bot bedevere-bot added the awaiting review label Apr 10, 2023
@sobolevn sobolevn added skip news needs backport to 3.11 only security fixes labels Apr 10, 2023
@sobolevn

sobolevn commented Apr 10, 2023

Copy link
Copy Markdown
Member Author

I am not sure about 3.10 backport 🤔

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn

sobolevn commented Apr 11, 2023

Copy link
Copy Markdown
Member Author

@JelleZijlstra would you have time to take a look, please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra
JelleZijlstra self-requested a review April 11, 2023 06:47
JelleZijlstra
JelleZijlstra reviewed Apr 14, 2023
View reviewed changes
Comment thread Lib/test/test_inspect.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_inspect.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn
Address review
8b0efa2
@sobolevn

sobolevn commented Apr 14, 2023

Copy link
Copy Markdown
Member Author

Thank you for the review! 🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sobolevn added 2 commits April 14, 2023 09:27
@sobolevn
Merge branch 'main' into issue-103406
fb20e9e
@sobolevn
Add new test
388c912
JelleZijlstra
JelleZijlstra approved these changes Apr 14, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Apr 14, 2023
@JelleZijlstra
JelleZijlstra merged commit 7569781 into python:main Apr 14, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 14, 2023
@miss-islington

miss-islington commented Apr 14, 2023

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Apr 14, 2023

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Apr 14, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 14, 2023
@sobolevn @miss-islington
pythongh-103406: Modernize pos-only arguments usage in `test_signatur…
4114451
…e` (pythonGH-103407)

(cherry picked from commit 7569781)

Co-authored-by: Nikita Sobolev <[email protected]>
miss-islington added a commit that referenced this pull request Apr 14, 2023
@miss-islington @sobolevn
gh-103406: Modernize pos-only arguments usage in test_signature (GH…
2e0ead5
…-103407)

(cherry picked from commit 7569781)

Co-authored-by: Nikita Sobolev <[email protected]>
carljm added a commit to carljm/cpython that referenced this pull request Apr 14, 2023
@carljm
Merge branch 'main' into superopt
64da49f
* main:
  pythongh-103532: Remove TKINTER_PROTECT_LOADTK code (pythonGH-103535)
  pythongh-103180: Add CI timeouts to all GitHub Actions jobs (python#103437)
  Remove double space in import error message (python#103458)
  ipaddress: Remove non-existent ip_str param from docstring (python#103461)
  Fix syntax typo in isolating extensions doc (python#103516)
  pythongh-103406: Modernize pos-only arguments usage in `test_signature` (python#103407)
  Proofread howto/perf_profiling.rst (python#103530)
  Fix unused functions warnings in instrumentation.c (pythonGH-103515)
carljm added a commit to carljm/cpython that referenced this pull request Apr 14, 2023
@carljm
Merge branch 'superopt' into superopt_spec
b73cff0
* superopt:
  fix incompatible types
  update generated cases
  don't unnecessarily re-find args in error case
  Apply suggestions from code review
  pythongh-103532: Remove TKINTER_PROTECT_LOADTK code (pythonGH-103535)
  pythongh-103180: Add CI timeouts to all GitHub Actions jobs (python#103437)
  Remove double space in import error message (python#103458)
  ipaddress: Remove non-existent ip_str param from docstring (python#103461)
  Fix syntax typo in isolating extensions doc (python#103516)
  pythongh-103406: Modernize pos-only arguments usage in `test_signature` (python#103407)
  Proofread howto/perf_profiling.rst (python#103530)
  Fix unused functions warnings in instrumentation.c (pythonGH-103515)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@sobolevn @miss-islington @bedevere-bot @JelleZijlstra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.