-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Modernize test_inspect
by adding real pos-only parameters
#103406
Comments
Since all supported Python versions have pos-only parameters this can be backported to reduce the amount of potential future merge conflicts. |
Ok, some code samples that I've listed cannot be replaced, because they test different things. But, some - can be. |
sobolevn
added a commit
to sobolevn/cpython
that referenced
this issue
Apr 10, 2023
This was referenced Apr 10, 2023
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Apr 14, 2023
…e` (pythonGH-103407) (cherry picked from commit 7569781) Co-authored-by: Nikita Sobolev <[email protected]>
JelleZijlstra
pushed a commit
that referenced
this issue
Apr 14, 2023
miss-islington
added a commit
that referenced
this issue
Apr 14, 2023
…-103407) (cherry picked from commit 7569781) Co-authored-by: Nikita Sobolev <[email protected]>
carljm
added a commit
to carljm/cpython
that referenced
this issue
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 issue
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)
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now
test_inspect
uses several hacks to pretend that some parameters are positional only:cpython/Lib/test/test_inspect.py
Lines 2465 to 2469 in ecad802
cpython/Lib/test/test_inspect.py
Lines 2519 to 2522 in ecad802
cpython/Lib/test/test_inspect.py
Lines 3047 to 3052 in ecad802
cpython/Lib/test/test_inspect.py
Lines 3559 to 3565 in ecad802
cpython/Lib/test/test_inspect.py
Lines 4160 to 4166 in ecad802
And maybe others.
It makes code more complex, unclear, and hides the real purpose of these tests.
This is not a design decision, but rather a limitation at the time. Commits are quite old and pos-only syntax was not available 9 and 11 years ago:
So, I propose to simplify these tests and make them more correct by using explicit pos only parameters.
Plus, we can keep one test like this to be sure that chaning a parameter kind still works as before. But, there's no need in keeping these old tests the way they are.
I will send a PR with the fix 👍
Linked PRs
test_signature
#103407test_signature
(GH-103407) #103536The text was updated successfully, but these errors were encountered: