brentyi / tyro

CLI interfaces & config objects, from types
https://brentyi.github.io/tyro
MIT License
469 stars 24 forks source link

unbound method type.mro() needs an argument #104

Closed grauvictor closed 9 months ago

grauvictor commented 9 months ago

I get the following error:

File "/home/victor/venv-python3.9-llm-explo/lib/python3.9/site-packages/tyro/_docstrings.py", line 121, in get_class_tokenization_with_field
    classes_to_search = cls.mro()
TypeError: unbound method type.mro() needs an argument

Du to the following line: https://github.com/brentyi/tyro/blob/152b889ef293aaa03f74843b378d1a37bd630700/tyro/_docstrings.py#L120

Called on the following type: <class 'pydantic.v1.main.ModelMetaclass'>

Suggestion: Replace https://github.com/brentyi/tyro/blob/152b889ef293aaa03f74843b378d1a37bd630700/tyro/_docstrings.py#L120 by: classes_to_search = cls.__mro__

brentyi commented 9 months ago

Hi, thanks for filing this issue and the fix suggestion!

Are you able to share a runnable example for reproducing the error? The fix seems reasonable, but I'm not fully following the root cause of the problem (particularly in what situation the cls value gets set to a metaclass) and it'd be nice to include this case in the unit tests.