Breaks with `from __future__ import annotations`
See original GitHub issueWhen using from __future__ import annotations
at the top of any of the examples, SimpleParsing
crashes with:
...
File "/Users/jrueegg/miniconda/envs/shrek/lib/python3.7/site-packages/simple_parsing/parsing.py", line 221, in _preprocessing
wrapper.add_arguments(parser=self)
File "/Users/jrueegg/miniconda/envs/shrek/lib/python3.7/site-packages/simple_parsing/wrappers/dataclass_wrapper.py", line 103, in add_arguments
group.add_argument(*wrapped_field.option_strings, **wrapped_field.arg_options)
File "/Users/jrueegg/miniconda/envs/shrek/lib/python3.7/argparse.py", line 1364, in add_argument
raise ValueError('%r is not callable' % (type_func,))
ValueError: 'str' is not callable
I guess you’re missing a typing.get_type_hints() somewhere in the code…
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
from __future__ import annotations - python - Stack Overflow
In python doc about __future__ there is a table below where it shows that annotations "optional in" 3.7.0b1 and "mandatory in" 4.0 but...
Read more >Import of __future__ annotations breaks ... - GitHub
I'm running across this problem in Python 3.8 WITHOUT the from __future__ import annotations statement (postponed evaluation of type hints is ...
Read more >Issue 33453: from __future__ import ...
This is broken in 3.7 (both beta 3 and 4): from __future__ import annotations from dataclasses import dataclass from typing import ClassVar, ...
Read more >from __future__ import annotations is broken in the interactive ...
from __future__ import annotations is broken in the interactive command line. this fails on PyPy3.7: Python 3.7.9 (7e6e2bb30ac5, ...
Read more >What are Python __future__ imports? - YouTube
Imports from the future ! ... This facilitates a transition away from code that uses the flawed or broken original version of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good point! I think the codebase currently heavily depends on the annotations being evaluated (e.g. on the
type
attribute of thedataclasess.Field
objects to be a ‘live’ type (<class str>
and not just"str"
)) so using this postponed evaluation option (which I’ll admit I’m not yet familiar with) might break a few things… I’ll try and give this a go and I’ll get back to you.Solved by #111