-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
diagnosticspriority-1-normaltopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributestopic-error-reportingHow we report errorsHow we report errorstopic-usability
Description
The following does not seem to work:
from typing import overload
class Example:
@overload
def fun(self, p: int) -> int: ...
@overload
def fun(self, p: str) -> str: ...
def fun(self, p=1):
if isinstance(p, int):
return 'foo'
else:
return 'bar'
prop = property(fun)
Argument 1 to "property" has incompatible type overloaded function; expected "Optional[Callable[[Any], Any]]"
Is this a bug or expected?
Also, fun(0)
returns a string instead of an int as specified in the stub, but mypy doesn't seem to catch this. Again, bug or expected?
Metadata
Metadata
Assignees
Labels
diagnosticspriority-1-normaltopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributestopic-error-reportingHow we report errorsHow we report errorstopic-usability