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
{{ message }}
Repository navigation
No validation on erroneous creation of 2 or more parameter variables (VAR_KEYWORD and VAR_POSITIONAL) in inspect.Signature #127610
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.
Activity
Eclips4 commentedon Dec 4, 2024
cc @serhiy-storchaka
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:
skirpichev commentedon Dec 5, 2024
Definitely is a bug. Why do we want to produce syntactically incorrect Signature objects?!
serhiy-storchaka commentedon Dec 5, 2024
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.
gh-127610: Added validation for more than one var-positional and var-…
serhiy-storchaka commentedon Dec 8, 2024
Thank you for your contribution, @ApostolFet.
pythongh-127610: Added validation for more than one var-positional an…