-
-
Notifications
You must be signed in to change notification settings - Fork 680
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
[FEATURE] Make typer compatible with PEP 563 #43
Labels
feature
New feature, enhancement or request
Comments
tiangolo
changed the title
[BUG] Make typer compatible with PEP 563
[FEATURE] Make typer compatible with PEP 563
Apr 26, 2020
tiangolo
added
feature
New feature, enhancement or request
and removed
bug
Something isn't working
labels
Apr 26, 2020
This is now supported as of version |
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues. |
This does not work anymore Sample code: from __future__ import annotations
import typer
app = typer.Typer()
def main():
app()
@app.command()
def test(flag: list[str] = typer.Option(None, "--flag", "-f", help="A flag")):
print(flag)
if __name__ == "__main__":
main() Error: Traceback (most recent call last):
File "test.py", line 18, in <module>
main()
File "test.py", line 9, in main
app()
File "/home/pop-os/.cache/pypoetry/virtualenvs/nala-j_krjJMS-py3.8/lib/python3.8/site-packages/typer/main.py", line 214, in __call__
return get_command(self)(*args, **kwargs)
File "/home/pop-os/.cache/pypoetry/virtualenvs/nala-j_krjJMS-py3.8/lib/python3.8/site-packages/typer/main.py", line 239, in get_command
click_command = get_command_from_info(typer_instance.registered_commands[0])
File "/home/pop-os/.cache/pypoetry/virtualenvs/nala-j_krjJMS-py3.8/lib/python3.8/site-packages/typer/main.py", line 425, in get_command_from_info
) = get_params_convertors_ctx_param_name_from_function(command_info.callback)
File "/home/pop-os/.cache/pypoetry/virtualenvs/nala-j_krjJMS-py3.8/lib/python3.8/site-packages/typer/main.py", line 401, in get_params_convertors_ctx_param_name_from_function
parameters = get_params_from_function(callback)
File "/home/pop-os/.cache/pypoetry/virtualenvs/nala-j_krjJMS-py3.8/lib/python3.8/site-packages/typer/utils.py", line 11, in get_params_from_function
type_hints = get_type_hints(func)
File "/usr/lib/python3.8/typing.py", line 1264, in get_type_hints
value = _eval_type(value, globalns, localns)
File "/usr/lib/python3.8/typing.py", line 270, in _eval_type
return t._evaluate(globalns, localns)
File "/usr/lib/python3.8/typing.py", line 518, in _evaluate
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in <module>
TypeError: 'type' object is not subscriptable Related issue: #371 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
https://www.python.org/dev/peps/pep-0563/
To Reproduce
Add
The text was updated successfully, but these errors were encountered: