question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breaks with `from __future__ import annotations`

See original GitHub issue

When 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
lebricecommented, Jun 27, 2021

Good point! I think the codebase currently heavily depends on the annotations being evaluated (e.g. on the type attribute of the dataclasess.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.

0reactions
lebricecommented, Oct 20, 2022

Solved by #111

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found