-
Notifications
You must be signed in to change notification settings - Fork 763
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
Type annotations for functions are absent #3048
Comments
I think the default value is intentional at the moment
See #2784 |
BTW, type annotations are actually not supported in Python 3.11.0 (main, Oct 25 2022, 16:25:24) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(): pass
...
>>> import inspect
>>> inspect.signature(f)
<Signature ()>
>>> f.__text_signature__ = "(a:int, b:bool)"
>>> inspect.signature(f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/messense/.pyenv/versions/3.11.0/lib/python3.11/inspect.py", line 3272, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/messense/.pyenv/versions/3.11.0/lib/python3.11/inspect.py", line 3020, in from_callable
return _signature_from_callable(obj, sigcls=cls,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/messense/.pyenv/versions/3.11.0/lib/python3.11/inspect.py", line 2507, in _signature_from_callable
return _signature_from_function(sigcls, obj,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/messense/.pyenv/versions/3.11.0/lib/python3.11/inspect.py", line 2342, in _signature_from_function
return _signature_fromstr(cls, func, s, skip_bound_arg)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/messense/.pyenv/versions/3.11.0/lib/python3.11/inspect.py", line 2272, in _signature_fromstr
p(name, default)
File "/Users/messense/.pyenv/versions/3.11.0/lib/python3.11/inspect.py", line 2249, in p
name = parse_name(name_node)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/messense/.pyenv/versions/3.11.0/lib/python3.11/inspect.py", line 2214, in parse_name
raise ValueError("Annotations are not currently supported")
ValueError: Annotations are not currently supported
>>> |
I think we should close this in favor of #2863? |
Yeah I think that's a good idea |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Description
There aren't type annotation when using
inspect.signature
for everything but Options, which produce a Ellipsis as default argument.Steps to Reproduce
running the python code would produce:
(a, b=Ellipsis)
Backtrace
No response
Your operating system and version
Windows
Your Python version (
python --version
)3.11.2
Your Rust version (
rustc --version
)rustc 1.68.0 (2c8cc3432 2023-03-06)
Your PyO3 version
0.18.1
How did you install python? Did you use a virtualenv?
python.org, a virtualenv with maturin was used
Additional Info
No response
The text was updated successfully, but these errors were encountered: