-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Closed as not planned
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Bug report
Bug description:
The documentation states:
parameters
An ordered mapping of parameters’ names to the corresponding Parameter objects.
This is incorrect and it should actually be an iterable, as that is how the code treats it. If you pass it a mapping, the code will iterate over it, and only obtain the keys, and not the values.
import inspect
def foo(arg):
...
sig = inspect.signature(foo)
print(repr(sig.parameters))
sig.replace(parameters=sig.parameters)
mappingproxy(OrderedDict({'arg': <Parameter "arg">}))
Traceback (most recent call last):
File "/tmp/test.py", line 9, in <module>
sig.replace(parameters=sig.parameters)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/inspect.py", line 3094, in replace
return type(self)(parameters,
~~~~~~~~~~^^^^^^^^^^^^
return_annotation=return_annotation)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/inspect.py", line 3029, in __init__
kind = param.kind
^^^^^^^^^^
AttributeError: 'str' object has no attribute 'kind'. Did you mean: 'find'?
Tested on 3.13.2
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo