-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Labels
bugSomething isn't workingSomething isn't working
Description
When the file where the class is defined has from __future__ import annotations, and the class have type hints on its __init__ function, tapify will throw ValueError: 'str' is not callable.
My Python version is Python 3.12.4. Tap version is 1.11.0.
Examples:
This will work fine:
# main.py
class Driver:
def __init__(self, a: str):
self.a = a
def run(self):
pass
def main():
from tap import tapify
tapify(Driver).run()
if __name__ == "__main__":
main()Running python main.py will correctly show help messages.
This will throw an error:
# main.py
from __future__ import annotations
class Driver:
def __init__(self, a: str):
self.a = a
def run(self):
pass
def main():
from tap import tapify
tapify(Driver).run()
if __name__ == "__main__":
main()Running python main.py results in this:
Traceback (most recent call last):
File "/***/main.py", line 19, in <module>
main()
File "/***/main.py", line 15, in main
tapify(Driver).run()
^^^^^^^^^^^^^^
File "/***/.venv/lib/python3.12/site-packages/tap/tapify.py", line 344, in tapify
tap = tap_class(description=description, explicit_bool=explicit_bool, underscores_to_dashes=underscores_to_dashes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/***/.venv/lib/python3.12/site-packages/tap/tap.py", line 112, in __init__
self._configure()
File "/***/.venv/lib/python3.12/site-packages/tap/tapify.py", line 292, in _configure
super()._configure()
File "/***/.venv/lib/python3.12/site-packages/tap/tap.py", line 352, in _configure
self._add_arguments()
File "/***/.venv/lib/python3.12/site-packages/tap/tap.py", line 312, in _add_arguments
self._add_argument(*name_or_flags, **kwargs)
File "/***/.venv/lib/python3.12/site-packages/tap/tap.py", line 292, in _add_argument
super(Tap, self).add_argument(*name_or_flags, **kwargs)
File "/***/lib/python3.12/argparse.py", line 1482, in add_argument
raise ValueError('%r is not callable' % (type_func,))
ValueError: 'str' is not callable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working