-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributestopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
I have the following decorator:
from typing import Type, Any
def generate_str(cls: Type) -> Type:
"""
Class decorator that auto generates __str__().
:param cls: class to modify
:return: modified class
"""
def __str__(self) -> str:
return _pretty_print_obj(self)
cls.__str__ = __str__
return cls
Mypy 0.521 on Python 3.6.2 emits this warning:
error: Incompatible types in assignment (expression has type Callable[[Any], str], variable has type Callable[[], str])
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributestopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly