-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug (Linux, Python 3.12): Cannot handle "GenericAlias" generated by "TypeAliasType" correctly. #177
Comments
Hi @opposj, thanks for the succinct reproduction instructions! This should be fixed in the latest release; if you have any more problems please let me know! |
Sorry, I realized there are actually more issues. Next release will have them fixed... |
Great work👍! I am currently enjoying the powerful extensiveness of tyro in my project. However, I have to customize tyro a little (by adding a new marker) to support parsing non-nested Iterable in a way like "--iterable=[ele1,ele2,[ele3,ele4]] → iterable = [ele1, ele2, [ele3, ele4]]". I wonder whether it is fine to add this optional feature to tyro? |
Sounds cool! If it's flexible enough I'd be happy to review a PR. Maybe this use case could also be covered by the custom constructor API? Which I'm also planning to revamp, cc #185. |
The constructor is what I tried first, where the same issue as #183 happened to me. It seems that after the update of "0.8.14", the help text can be generated in a more intuitive style according to #185 (although I still prefer the separated grouped options for a constructor). However, the metavar and default value in the help text may not convey correct information of the expected type. For example, when a list of int is required I'm not sure whether a updated constructor API can implement this feature or not. If a future update covers this feature, I think it unnecessary to provide a new marker, which is realized via adapting the inner instantiator and help text generation. |
Bug Description
When using a
GenericAlias
generated by aTypeAliasType
as the type hint,AssertionError
occurs in the following code snippet:tyro/src/tyro/_resolver.py
Lines 426 to 431 in 8828943
To Reproduce
Additional Context
The
TT
is an instance of "TypeAliasType", which does not possess a__class_getitem__
. However, it seems that the__getitem__
method can work as expected to generate a copied "GenericAlias". Deliberate considerations may be required to design the branching conditions in the previous code snippet.The text was updated successfully, but these errors were encountered: