We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Literal
from classes import typeclass from typing import Literal class _Car(type): def __instancecheck__(self, instance) -> bool: return isinstance(instance, str) and instance == "car" class Car(str, metaclass=_Car): ... class _Pony(type): def __instancecheck__(self, instance) -> bool: return isinstance(instance, str) and instance == "pony" class Pony(str, metaclass=_Pony): ... @typeclass def get_repr(type, name: str) -> str: pass @get_repr.instance(delegate=Pony) # error: Instance "Literal['pony']" does not match inferred type "t.Pony*" def _pony(type: Literal["pony"], name: str) -> str: return f"Pony {name}" @get_repr.instance(delegate=Car) # error: Instance "Literal['car']" does not match inferred type "t.Car*" def _car(type: Literal["car"], name: str) -> str: return f"Car {name}" if __name__ == "__main__": print(get_repr('car', 'test')) # error: Argument 1 to "get_repr" has incompatible type "str"; expected <nothing>
python
classes
mypy
The text was updated successfully, but these errors were encountered:
Thanks for your issue, Literal is not supported yet!
Related #274
Sorry, something went wrong.
I guess we can close it in favor of #274 🙂
No branches or pull requests
Bug report
What's wrong
How is that should be
System information
python
version: 3.9.6classes
version: 0.4.0mypy
version: 0.910The text was updated successfully, but these errors were encountered: