Typer/Cython - anyone ever used it? #684
-
First Check
Commit to Help
Example Codeimport typer
def main(user_name: Optional[List[str]] = typer.Option("Theo", "--user-name", "-n")):
print(f"Hello {user_name}") DescriptionPython 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Operating SystemLinux Operating System DetailsCython==3.0.4 Typer Version0.9.0 Python Version3.10.6 Additional ContextWell it seems that i having some issues with code that has been cythonized and typer is being as a CLI, is there any past experience or recommendation on how to fix the above issue? The annotated syntax is not working ( Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Not sure if anyone ever used Typer with Cython but the |
Beta Was this translation helpful? Give feedback.
-
It seems that the problem is in this line: Cython enables I am currently monkey-patching Typer as follows to workaround this: import inspect
import typer.utils
class _inspect:
@staticmethod
def signature(func, *args, **kwargs):
eval_str = kwargs.pop("eval_str", True)
return inspect.signature(func, *args, **kwargs, eval_str=eval_str)
typer.utils.inspect = _inspect |
Beta Was this translation helpful? Give feedback.
-
Related PR: #721 |
Beta Was this translation helpful? Give feedback.
Thanks for the report @theodore86!
This was indeed (probably) solved by #721, available in Typer 0.9.3, released in the next few hours. 🚀