Skip to content
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

gh-103406: Modernize pos-only arguments usage in test_signature #103407

Merged
merged 4 commits into from
Apr 14, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Apr 10, 2023

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

@sobolevn
Copy link
Member Author

I am not sure about 3.10 backport 🤔

@sobolevn
Copy link
Member Author

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

@JelleZijlstra JelleZijlstra self-requested a review April 11, 2023 06:47
Lib/test/test_inspect.py Outdated Show resolved Hide resolved
Lib/test/test_inspect.py Show resolved Hide resolved
@sobolevn
Copy link
Member Author

Thank you for the review! 🎉

@JelleZijlstra JelleZijlstra merged commit 7569781 into python:main Apr 14, 2023
13 checks passed
@miss-islington
Copy link
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!

@bedevere-bot
Copy link

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

@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
…e` (pythonGH-103407)

(cherry picked from commit 7569781)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington added a commit that referenced this pull request Apr 14, 2023
…-103407)

(cherry picked from commit 7569781)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
carljm added a commit to carljm/cpython that referenced this pull request Apr 14, 2023
* 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
* 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
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants