Closed AdamWill closed 4 months ago
@serhiy-storchaka, I think you added lots of signatures for builtins in py313?
map(function, iterable, /, *iterables)
looks more correct for this case.
I am sending a PR to fix it, yep.
Indeed. Thank you for correction @AdamWill.
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 like `myfunc(args), it does not require any arguments. But really, for
map`, 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