mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-10 21:42:25 +08:00
Always use _typeshed.Self, where applicable (#6880)
* Always use `_typeshed.Self`, where applicable * Revert changes to `google-cloud-ndb` (ambiguous) * Remove empty line added by script * Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi` * Manually add a few more that the script missed * Improve `filelock` annotation Source code here:79ec7b2826/src/filelock/_api.py (L207)* Improve `opentracing/scope` annotation Source code here:3e1d357a34/opentracing/scope.py (L71)* Improve `redis/client` stub Source code here:15f315a496/redis/client.py (L1217)* Improve `redis/lock` annotation Source code here:15f315a496/redis/lock.py (L155)* Improve `requests/models` annotation Source code here:d718e75383/requests/models.py (L653)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from typing import Any, Container, Generic, Iterable, Iterator, SupportsInt, TypeVar, overload
|
||||
|
||||
# Undocumented length constants
|
||||
@@ -7,7 +8,6 @@ IPV6LENGTH: int
|
||||
|
||||
_A = TypeVar("_A", IPv4Address, IPv6Address)
|
||||
_N = TypeVar("_N", IPv4Network, IPv6Network)
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def ip_address(address: object) -> IPv4Address | IPv6Address: ...
|
||||
def ip_network(address: object, strict: bool = ...) -> IPv4Network | IPv6Network: ...
|
||||
@@ -15,10 +15,10 @@ def ip_interface(address: object) -> IPv4Interface | IPv6Interface: ...
|
||||
|
||||
class _IPAddressBase:
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
def __ge__(self: _T, other: _T) -> bool: ...
|
||||
def __gt__(self: _T, other: _T) -> bool: ...
|
||||
def __le__(self: _T, other: _T) -> bool: ...
|
||||
def __lt__(self: _T, other: _T) -> bool: ...
|
||||
def __ge__(self: Self, other: Self) -> bool: ...
|
||||
def __gt__(self: Self, other: Self) -> bool: ...
|
||||
def __le__(self: Self, other: Self) -> bool: ...
|
||||
def __lt__(self: Self, other: Self) -> bool: ...
|
||||
def __ne__(self, other: Any) -> bool: ...
|
||||
@property
|
||||
def compressed(self) -> str: ...
|
||||
@@ -31,10 +31,10 @@ class _IPAddressBase:
|
||||
|
||||
class _BaseAddress(_IPAddressBase, SupportsInt):
|
||||
def __init__(self, address: object) -> None: ...
|
||||
def __add__(self: _T, other: int) -> _T: ...
|
||||
def __add__(self: Self, other: int) -> Self: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __int__(self) -> int: ...
|
||||
def __sub__(self: _T, other: int) -> _T: ...
|
||||
def __sub__(self: Self, other: int) -> Self: ...
|
||||
@property
|
||||
def is_global(self) -> bool: ...
|
||||
@property
|
||||
@@ -61,10 +61,10 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
|
||||
def __contains__(self, other: Any) -> bool: ...
|
||||
def __getitem__(self, n: int) -> _A: ...
|
||||
def __iter__(self) -> Iterator[_A]: ...
|
||||
def address_exclude(self: _T, other: _T) -> Iterator[_T]: ...
|
||||
def address_exclude(self: Self, other: Self) -> Iterator[Self]: ...
|
||||
@property
|
||||
def broadcast_address(self) -> _A: ...
|
||||
def compare_networks(self: _T, other: _T) -> int: ...
|
||||
def compare_networks(self: Self, other: Self) -> int: ...
|
||||
def hosts(self) -> Iterator[_A]: ...
|
||||
@property
|
||||
def is_global(self) -> bool: ...
|
||||
@@ -88,10 +88,10 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
|
||||
@property
|
||||
def prefixlen(self) -> int: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def subnet_of(self: _T, other: _T) -> bool: ...
|
||||
def supernet_of(self: _T, other: _T) -> bool: ...
|
||||
def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> Iterator[_T]: ...
|
||||
def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> _T: ...
|
||||
def subnet_of(self: Self, other: Self) -> bool: ...
|
||||
def supernet_of(self: Self, other: Self) -> bool: ...
|
||||
def subnets(self: Self, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> Iterator[Self]: ...
|
||||
def supernet(self: Self, prefixlen_diff: int = ..., new_prefix: int | None = ...) -> Self: ...
|
||||
@property
|
||||
def with_hostmask(self) -> str: ...
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user