Open ljstella opened 3 hours ago
Hi @ljstella, thanks for filing the issue!
I can reproduce the error message you're seeing with this example:
import enum
import tyro
class SomeEnum(enum.StrEnum):
A = enum.auto()
B = enum.auto()
def main(x: SomeEnum = "A"): # this should create a type error!
print(x)
tyro.cli(main)
In contentctl
, it looks like a similar case is hit because you have use_enum_values=True
in your Pydantic models, which unfortunately creates many situations where the static type (an enum) doesn't match the runtime type (a string).
It's hard for me to generally support type mismatches like this, but I can add a patch + tests today to suppress this specific error.
Hi @brentyi
Thanks for the super quick response! We're looking to migrate away from using use_enum_values
anyway- I thought that might be the issue, but wasn't positive. I would greatly appreciate a patch fix but if you can't or don't want to maintain it, we can move some things around and remove the use_enum_values
config that was causing this issue.
Stack Trace:
Getting this exact same stack trace on python3.11, 3.12, and 3.13 with the newest release with everything we try to do with our CLI. This codebase worked fine with 3.11 and 3.12 w/ tyro==0.8.14. Looks like there's some new changes, specifically
tyro/constructors/_primitive_spec.py
that are causing an issue for us, specifically here:Is there an issue here, or are there docs we can go through to port things so they continue to work going forward if this behavior is expected?