8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
ABC
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
Here's the code:
from abc import ABCMeta, abstractmethod from classes import typeclass @typeclass def my_typeclass(instance) -> int: """Example typeclass.""" class _MyABC(object, metaclass=ABCMeta): @abstractmethod def get_number(self) -> int: """Example abstract method.""" class _MyConcrete(_MyABC): def get_number(self) -> int: """Concrete method.""" return 1 def _my_abc(instance: _MyABC) -> int: return instance.get_number() my_typeclass.instance(_MyABC)(_my_abc) assert my_typeclass(_MyConcrete()) == 1
This works in runtime, but mypy reveals invalid type:
mypy
reveal_type(my_typeclass)
Reveals:
ex.py:48: note: Revealed type is "classes._typeclass._TypeClass[ex._MyABC, def (instance: ex._MyABC) -> builtins.int, <nothing>, Literal['ex.my_typeclass']]"
It should be:
ex.py:48: note: Revealed type is "classes._typeclass._TypeClass[ex._MyABC, def (instance: Any) -> builtins.int, <nothing>, Literal['ex.my_typeclass']]"
For some reason, first argument of our initial signature gets mutated.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Here's the code:
This works in runtime, but
mypy
reveals invalid type:Reveals:
It should be:
For some reason, first argument of our initial signature gets mutated.
The text was updated successfully, but these errors were encountered: