-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
from abc import ABC, abstractmethod
from typing import overload
class Foo(ABC):
@overload # error: An overloaded function outside a stub file must have an implementation
@abstractmethod
def foo(self, value: int) -> int:
...
@overload
@abstractmethod
def foo(self, value: str) -> str:
...
# (this fake impl shouldnt be necessary, that's the impl class's responsibility)
# @abstractmethod
# def foo(self, value: str | int) -> str | int:
# ...
class Bar(Foo):
@overload
def foo(self, value: int) -> int:
...
@overload
def foo(self, value: str) -> str:
...
def foo(self, value: str | int) -> str | int:
return 1
https://mypy-play.net/?mypy=latest&python=3.10&gist=9c19741f8c5682b5854d59f3cf5f9ade
the implementation on the abstract class serves no purpose and should not be required imo
KotlinIsland, DetachHead, thep0y, Talendar, majidaldo and 13 more