-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
inspect.signature(map)
works in Python 3.13, but gives a signature that looks like only one arg is required
#120526
Labels
type-bug
An unexpected behavior, bug, or error
Comments
@serhiy-storchaka, I think you added lots of signatures for builtins in py313? |
|
I am sending a PR to fix it, yep. |
AdamWill
added a commit
to AdamWill/cpython
that referenced
this issue
Jun 14, 2024
map requires at least one iterable arg. If you just do `map(map)` you get an error "map() must have at least two arguments." This corrects the signature to reflect this, in line with how it's shown in https://docs.python.org/3/library/functions.html#map . Signed-off-by: Adam Williamson <[email protected]>
AdamWill
added a commit
to AdamWill/cpython
that referenced
this issue
Jun 14, 2024
map requires at least one iterable arg. If you just do `map(map)` you get an error "map() must have at least two arguments." This corrects the signature to reflect this, in line with how it's shown in https://docs.python.org/3/library/functions.html#map . Signed-off-by: Adam Williamson <[email protected]>
AdamWill
added a commit
to AdamWill/cpython
that referenced
this issue
Jun 14, 2024
map requires at least one iterable arg. If you just do `map(map)` you get an error "map() must have at least two arguments." This corrects the signature to reflect this, in line with how it's shown in https://docs.python.org/3/library/functions.html#map . Signed-off-by: Adam Williamson <[email protected]>
AdamWill
added a commit
to AdamWill/cpython
that referenced
this issue
Jun 14, 2024
map requires at least one iterable arg. If you just do `map(map)` you get an error "map() must have at least two arguments." This corrects the signature to reflect this, in line with how it's shown in https://docs.python.org/3/library/functions.html#map . Signed-off-by: Adam Williamson <[email protected]>
serhiy-storchaka
pushed a commit
that referenced
this issue
Jun 15, 2024
map() requires at least one iterable arg. Signed-off-by: Adam Williamson <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 15, 2024
map() requires at least one iterable arg. (cherry picked from commit d4039d3) Co-authored-by: Adam Williamson <[email protected]> Signed-off-by: Adam Williamson <[email protected]>
Indeed. Thank you for correction @AdamWill. |
serhiy-storchaka
pushed a commit
that referenced
this issue
Jun 15, 2024
…120539) map() requires at least one iterable arg. (cherry picked from commit d4039d3) Signed-off-by: Adam Williamson <[email protected]> Co-authored-by: Adam Williamson <[email protected]>
mrahtz
pushed a commit
to mrahtz/cpython
that referenced
this issue
Jun 30, 2024
map() requires at least one iterable arg. Signed-off-by: Adam Williamson <[email protected]>
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
map() requires at least one iterable arg. Signed-off-by: Adam Williamson <[email protected]>
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
map() requires at least one iterable arg. Signed-off-by: Adam Williamson <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
Bug description:
Up to Python 3.12,
inspect.signature(map)
just doesn't work, it raisesValueError
. In 3.13, it works, but the signature you get seems like kind of a lie. Thetoolz
library has this code to work out how many arguments a function requires:where
sigspec
is the result ofinspect.signature(function)
. That code seems sensible to me. But it gives the wrong answer formap
, because the signature returned byinspect.signature(map)
says the "kind" of the second arg (iterables
) isVAR_POSITIONAL
, which the docs say "corresponds to a *args parameter in a Python function definition". That does make it seem optional, because of course if you define a function likemyfunc(*args)
, it does not require any arguments. But really, formap
, you have to provide at least one iterable, or you get the error "map() must have at least two arguments." from https://github.com/python/cpython/blob/b2e71ff4f8fa5b7d8117dd8125137aee3d01f015/Python/bltinmodule.c#L1322C12-L1322C53 .It kinda seems to me like maybe the signature of
map
should show three args, the first onePOSITIONAL_ONLY
, the second (iterable
)POSITIONAL_OR_KEYWORD
, and the third (*iterables
)VAR_POSITIONAL
? This is how it looks in the docs.toolz can work around this by special-casing
map
one way or another, but it seemed worth at least reporting upstream.CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: