-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Overriding of methods with self types #2353
New issue
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
Comments
I tried to left a (really long) comment here a week ago. But it looks like something went wrong. I suppose I just forgot to press "Comment" :-( It is difficult to reproduce it again now, but very short summary is: Now I am in favour of option (4) you proposed in #2193 (comment) |
Agreed. |
The duplicate issue #2511 has a relevant example that has a class method. |
The following example seems related to this issue: S = TypeVar("S")
T = TypeVar("T")
F = TypeVar("F", bound="Foo[Any, Any]")
class Foo(Generic[S, T]):
def test(self: F) -> F:
raise NotImplementedError
B = TypeVar("B", bound="Bar[Any]")
class Bar(Foo[int, T], Generic[T]):
def test(self: B) -> B:
return self mypy tells me As requested by @ilevkivskyi on gitter, I am adding a comment here. |
@tyrion wondering if there was any progress made on this or if there is a workaround? |
It's unclear how we should check overrides of methods that use self types (e.g.
self: T
). There is some discussion in #2193.A relevant comment (but there are others): #2193 (comment)
The text was updated successfully, but these errors were encountered: