mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:24:57 +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):
|
||||
|
|
|
@ -103,6 +103,6 @@ class NamedTupleLike(Protocol):
|
|||
@classmethod
|
||||
def _make(cls: type[Self], iterable: Iterable[Any]) -> Self: ...
|
||||
def _asdict(self, /) -> dict[str, Any]: ...
|
||||
def _replace(self: Self, /, **kwargs) -> Self: ...
|
||||
def _replace(self, /, **kwargs) -> Self: ...
|
||||
if sys.version_info >= (3, 13):
|
||||
def __replace__(self: Self, **kwargs) -> Self: ...
|
||||
def __replace__(self, **kwargs) -> Self: ...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue