Relative Content

Tag Archive for pythonmypypython-typingstatic-analysispyright

“Variable not allowed in type expression” – how can I create parameterized typing.Annotated types?

I’m not sure if this is possible in Python, but I’d like to create a series of related typing.Annotated referring to the same underlying type, but where each is constrained to a different set of values (ideally using enums, but that isn’t crucial), and annotated with metadata about what it accepts. I could manually specify them all, but it would be cleaner if this could be parameterized.