Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-36540: PEP 570 -- Implementation #12701
Conversation
the-knights-who-say-ni
added
the
CLA signed
label
Apr 6, 2019
bedevere-bot
added
the
awaiting core review
label
Apr 6, 2019
pablogsal
force-pushed the
pablogsal:PEP570
branch
from
f10ff2b
to
a4cf907
Apr 6, 2019
brettcannon
added
the
DO-NOT-MERGE
label
Apr 6, 2019
pablogsal
changed the title
[WIP] Implement PEP570
bpo-36540: Implement PEP570
Apr 6, 2019
pablogsal
changed the title
bpo-36540: Implement PEP570
bpo-36540: Implement PEP570 [WIP]
Apr 6, 2019
pablogsal
marked this pull request as ready for review
Apr 6, 2019
pablogsal
requested a review
from
rhettinger
as a
code owner
Apr 6, 2019
pablogsal
changed the title
bpo-36540: Implement PEP570 [WIP]
bpo-36540: Implement PEP 570 [WIP]
Apr 6, 2019
pablogsal
force-pushed the
pablogsal:PEP570
branch
from
a4cf907
to
39d75e6
Apr 6, 2019
pablogsal
added
skip issue
skip news
and removed
skip issue
skip news
labels
Apr 6, 2019
willingc
self-requested a review
Apr 6, 2019
pablogsal
force-pushed the
pablogsal:PEP570
branch
4 times, most recently
from
ea3de2e
to
08f02c6
Apr 6, 2019
pablogsal
self-assigned this
Apr 6, 2019
pganssle
suggested changes
Apr 7, 2019
|
Some comments here from a very cursory pass over this. Is the documentation for this intended to be part of a separate PR? Either way, feel free to ping me for a review when it's available. |
pablogsal
force-pushed the
pablogsal:PEP570
branch
4 times, most recently
from
19b27b3
to
7e77d2f
Apr 8, 2019
pablogsal
changed the title
bpo-36540: Implement PEP 570 [WIP]
bpo-36540: Implement PEP 570
Apr 13, 2019
pablogsal
changed the title
bpo-36540: Implement PEP 570
bpo-36540: PEP 570 -- Implementation
Apr 13, 2019
pablogsal
requested review from
vstinner and
serhiy-storchaka
Apr 13, 2019
pablogsal
removed
the
DO-NOT-MERGE
label
Apr 13, 2019
pablogsal
force-pushed the
pablogsal:PEP570
branch
from
dbe7f2b
to
f42bdd1
Apr 24, 2019
This comment has been minimized.
This comment has been minimized.
|
@serhiy-storchaka Gentle ping for the review. As has been commented here and in other PRs, I would like to merge this before Alpha 4 if possible, so this can have more exposure and tested outside. We can do this without the inspect changes that you mentioned in the issue. Please, feel free to push directly to my branch if you want to change something or you spot some errors so we can reduce the time required for the review process. |
This comment has been minimized.
This comment has been minimized.
|
About changes of the inspect module and backward-compatibility, let me have a look.
Maybe something should be done for getfullargspec() and formatargspec(). |
This comment has been minimized.
This comment has been minimized.
|
getfullargspec() was deprecated but then became undeprecated again... https://bugs.python.org/issue20438 |
pablogsal
force-pushed the
pablogsal:PEP570
branch
from
f42bdd1
to
382fc3e
Apr 24, 2019
This comment has been minimized.
This comment has been minimized.
|
My advice is to merge this PR as it is. Maybe it's not perfect: that's ok. The important part is to get the new syntax as soon as possible, to get enough time to play with it before Python 3.8.0 final. I expect that subtle issue will be found, and I prefer to find them before the final rather than after. I suggest to leave inspect unchanged but open a new issue on bugs.python.org or open a thread on python-dev to decide how to handle the backward-compatibility. IMHO there is no good solution, only compromises. You cannot add support for positional-only arguments and leave the API unchanged. I'm talking about getargs(), getargspec(), getfullargspec() and formatargspec() functions. signature() is fine if I understood correctly. |
This comment has been minimized.
This comment has been minimized.
|
I have removed the changes in |
This comment has been minimized.
This comment has been minimized.
|
I'm not crazy about raising. Maybe just pretend the '/' isn't there? |
This comment has been minimized.
This comment has been minimized.
We already raise if you pass keyword only or an annotation for that API: https://github.com/python/cpython/blob/master/Lib/inspect.py#L1092 |
This comment has been minimized.
This comment has been minimized.
That was my proposal. IMHO it's the safest option for "legacy" functions of the inspect module, to ensure that we don't introduce any subtle backward-incompatible change. I modified the warnings module to add a new "source" parameter at the end. It took me 3 years to fix regressions on corner cases... The latest one was be7c460 See https://bugs.python.org/issue26568 and https://bugs.python.org/issue35178 I tried to have the backward-compatibility in mind when I modified the warnings module, but there are always subtle issues... IMHO getargs(), getargspec(), getfullargspec() should be deprecated in favor of signature() which is future-proof. But Nick Coghlan undeprecated these functions in 2017 https://bugs.python.org/issue20438 whereas these were deprecated since 2015. I didn't understand the subtle issues. Again, that's why I suggest to open an issue afterwards to discuss the subtle inspect API :-) |
pablogsal
added some commits
Apr 12, 2019
pablogsal
force-pushed the
pablogsal:PEP570
branch
from
382fc3e
to
afe86b9
Apr 24, 2019
This comment has been minimized.
This comment has been minimized.
|
Oh, then disregard what I said. |
This comment has been minimized.
This comment has been minimized.
|
As a side comment, Cython is already adding support for this PEP |
This comment has been minimized.
This comment has been minimized.
|
@pablogsal: Please merge your PR. Serhiy Storchaka complained about backward incompatible changes on the inspect module: But I made the same complain and you fixed it. IHMO the change is now good enough to be merged. Serhiy said nothing for 2 weeks. alpha4 release is today. I would prefer to get this implementation merged as soon as possible: as Lukasz if I understand correctly. |
This comment has been minimized.
This comment has been minimized.
|
My main complain was about the inspect module. I have no time to make a review of other parts, but I do not expect serious problems here. Feel free to commit. We can fix minor issues after merging if there are any. |
serhiy-storchaka
reviewed
Apr 29, 2019
Lib/inspect.py Outdated
| @@ -1185,7 +1193,7 @@ def getfullargspec(func): | |||
| defaults = None | |||
|
|
|||
| return FullArgSpec(args, varargs, varkw, defaults, | |||
This comment has been minimized.
This comment has been minimized.
serhiy-storchaka
Apr 29, 2019
Member
This is breaking change. getfullargspec() was added to avoid breaking old getargspec(). You need to add a new function (getfullerargspec()?) and deprecate getfullargspec().
This comment has been minimized.
This comment has been minimized.
pablogsal
Apr 29, 2019
Author
Member
I suspect that there may be a longer discussion for these cases so I opened https://bugs.python.org/issue36751 to track it and decide there.
| @@ -1216,7 +1224,8 @@ def _formatannotation(annotation): | |||
| return _formatannotation | |||
|
|
|||
| def formatargspec(args, varargs=None, varkw=None, defaults=None, | |||
| kwonlyargs=(), kwonlydefaults={}, annotations={}, | |||
| posonlyargs=(), kwonlyargs=(), kwonlydefaults={}, | |||
This comment has been minimized.
This comment has been minimized.
serhiy-storchaka
Apr 29, 2019
Member
Since all these parameters are positional-or-keyword, inserting a new parameter in the middle is breaking change. You can add it only to the end. Or add a new function.
This comment has been minimized.
This comment has been minimized.
pablogsal
Apr 29, 2019
Author
Member
I suspect that there may be a longer discussion for these cases so I opened https://bugs.python.org/issue36751 to track it and decide there.
Lib/inspect.py Outdated
Lib/test/test_type_comments.py Outdated
Objects/codeobject.c Outdated
Objects/codeobject.c Outdated
Objects/codeobject.c Outdated
This comment has been minimized.
This comment has been minimized.
Did you see that the PR has been modified to no longer touch the existing API, except of signature(), but raise an exception of the "legacy functions" are called on a function which has positional-only arguments? #12701 (comment) |
pablogsal
merged commit 8c77b8c
into
python:master
Apr 29, 2019
5 checks passed
bedevere-bot
removed
the
awaiting merge
label
Apr 29, 2019
pablogsal
deleted the
pablogsal:PEP570
branch
Apr 29, 2019
This comment has been minimized.
This comment has been minimized.
bedevere-bot
commented
Apr 29, 2019
|
This comment has been minimized.
This comment has been minimized.
False positive. It is some problem in the multiprocessing module. |
pablogsal commentedApr 6, 2019
•
edited
implementation of PEP 570 -- Python Positional-Only Parameters:
https://www.python.org/dev/peps/pep-0570/
https://bugs.python.org/issue36540
CC: @mariocj89