mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:14:52 +00:00
Remove more explicit Self
annotations
This commit is contained in:
parent
53404d340d
commit
b9a57d3eca
2 changed files with 6 additions and 10 deletions
|
@ -324,8 +324,7 @@ a covariant generic, this is equivalent to using the upper bound of the type par
|
|||
from typing import Self
|
||||
|
||||
class Covariant[T]:
|
||||
# TODO: remove the explicit `Self` annotation, once we support the implicit type of `self`
|
||||
def get(self: Self) -> T:
|
||||
def get(self) -> T:
|
||||
raise NotImplementedError
|
||||
|
||||
def _(x: object):
|
||||
|
@ -338,8 +337,7 @@ Similarly, contravariant type parameters use their lower bound of `Never`:
|
|||
|
||||
```py
|
||||
class Contravariant[T]:
|
||||
# TODO: remove the explicit `Self` annotation, once we support the implicit type of `self`
|
||||
def push(self: Self, x: T) -> None: ...
|
||||
def push(self, x: T) -> None: ...
|
||||
|
||||
def _(x: object):
|
||||
if isinstance(x, Contravariant):
|
||||
|
@ -354,10 +352,8 @@ the type system, so we represent it with the internal `Top[]` special form.
|
|||
|
||||
```py
|
||||
class Invariant[T]:
|
||||
# TODO: remove the explicit `Self` annotation, once we support the implicit type of `self`
|
||||
def push(self: Self, x: T) -> None: ...
|
||||
# TODO: remove the explicit `Self` annotation, once we support the implicit type of `self`
|
||||
def get(self: Self) -> T:
|
||||
def push(self, x: T) -> None: ...
|
||||
def get(self) -> T:
|
||||
raise NotImplementedError
|
||||
|
||||
def _(x: object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue