You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ApostolFet opened this issue
Dec 4, 2024
· 4 comments
Labels
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
File "/home/apostol_fet/inspect_signature.py", line 13
def func(*args, *other_args, **kwargs, **other_kwargs):
^
SyntaxError: * argument may appear only once
Can we add validations for this case in inspect.Signature.__init__?
I would like to send a PR to fix this if it is not intended behavior.
I do think that this check would be useful. We already have a check for situations where user is trying to create a signature with a variadic keyword parameter before a variadic positional parameter:
I agree. There are other checks for the order of parameters, for example positional or keyword parameter is not allowed before positional-only parameter. We should simply add more checks: for var-positional parameter before var-positional parameter and var-keyword parameter before any parameter.
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
Bug report
Bug description:
We can create
inspect.Signature
with two or more variable parameters, but this will be syntactically incorrect when defining the function manually:OUTPUT:
And naturally we get a syntax error when defining a function with such a signature:
OUTPUT:
Can we add validations for this case in
inspect.Signature.__init__
?I would like to send a PR to fix this if it is not intended behavior.
CPython versions tested on:
3.12
Operating systems tested on:
Linux, Windows
Linked PRs
The text was updated successfully, but these errors were encountered: