mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-02 17:43:25 +08:00
Avoid unnecessary forward refs in class definitions (#10124)
This commit is contained in:
@@ -208,13 +208,6 @@ def unique(enumeration: _EnumerationT) -> _EnumerationT: ...
|
||||
|
||||
_auto_null: Any
|
||||
|
||||
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
|
||||
class auto(IntFlag):
|
||||
_value_: Any
|
||||
@_magic_enum_attr
|
||||
def value(self) -> Any: ...
|
||||
def __new__(cls) -> Self: ...
|
||||
|
||||
class Flag(Enum):
|
||||
_name_: str | None # type: ignore[assignment]
|
||||
_value_: int
|
||||
@@ -235,27 +228,6 @@ class Flag(Enum):
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
# The body of the class is the same, but the base classes are different.
|
||||
class IntFlag(int, ReprEnum, Flag, boundary=KEEP): # type: ignore[misc] # complaints about incompatible bases
|
||||
def __new__(cls, value: int) -> Self: ...
|
||||
def __or__(self, other: int) -> Self: ...
|
||||
def __and__(self, other: int) -> Self: ...
|
||||
def __xor__(self, other: int) -> Self: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
else:
|
||||
class IntFlag(int, Flag): # type: ignore[misc] # complaints about incompatible bases
|
||||
def __new__(cls, value: int) -> Self: ...
|
||||
def __or__(self, other: int) -> Self: ...
|
||||
def __and__(self, other: int) -> Self: ...
|
||||
def __xor__(self, other: int) -> Self: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
class StrEnum(str, ReprEnum):
|
||||
def __new__(cls, value: str) -> Self: ...
|
||||
@@ -289,3 +261,31 @@ if sys.version_info >= (3, 11):
|
||||
def global_enum(cls: _EnumerationT, update_str: bool = False) -> _EnumerationT: ...
|
||||
def global_enum_repr(self: Enum) -> str: ...
|
||||
def global_flag_repr(self: Flag) -> str: ...
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
# The body of the class is the same, but the base classes are different.
|
||||
class IntFlag(int, ReprEnum, Flag, boundary=KEEP): # type: ignore[misc] # complaints about incompatible bases
|
||||
def __new__(cls, value: int) -> Self: ...
|
||||
def __or__(self, other: int) -> Self: ...
|
||||
def __and__(self, other: int) -> Self: ...
|
||||
def __xor__(self, other: int) -> Self: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
else:
|
||||
class IntFlag(int, Flag): # type: ignore[misc] # complaints about incompatible bases
|
||||
def __new__(cls, value: int) -> Self: ...
|
||||
def __or__(self, other: int) -> Self: ...
|
||||
def __and__(self, other: int) -> Self: ...
|
||||
def __xor__(self, other: int) -> Self: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
|
||||
class auto(IntFlag):
|
||||
_value_: Any
|
||||
@_magic_enum_attr
|
||||
def value(self) -> Any: ...
|
||||
def __new__(cls) -> Self: ...
|
||||
|
||||
@@ -14,9 +14,6 @@ class Barrier(threading.Barrier):
|
||||
self, parties: int, action: Callable[[], object] | None = None, timeout: float | None = None, *ctx: BaseContext
|
||||
) -> None: ...
|
||||
|
||||
class BoundedSemaphore(Semaphore):
|
||||
def __init__(self, value: int = 1, *, ctx: BaseContext) -> None: ...
|
||||
|
||||
class Condition(AbstractContextManager[bool]):
|
||||
def __init__(self, lock: _LockLike | None = None, *, ctx: BaseContext) -> None: ...
|
||||
def notify(self, n: int = 1) -> None: ...
|
||||
@@ -36,6 +33,14 @@ class Event:
|
||||
def clear(self) -> None: ...
|
||||
def wait(self, timeout: float | None = None) -> bool: ...
|
||||
|
||||
# Not part of public API
|
||||
class SemLock(AbstractContextManager[bool]):
|
||||
def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
def __exit__(
|
||||
self, __exc_type: type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
class Lock(SemLock):
|
||||
def __init__(self, *, ctx: BaseContext) -> None: ...
|
||||
|
||||
@@ -45,10 +50,5 @@ class RLock(SemLock):
|
||||
class Semaphore(SemLock):
|
||||
def __init__(self, value: int = 1, *, ctx: BaseContext) -> None: ...
|
||||
|
||||
# Not part of public API
|
||||
class SemLock(AbstractContextManager[bool]):
|
||||
def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ...
|
||||
def release(self) -> None: ...
|
||||
def __exit__(
|
||||
self, __exc_type: type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
class BoundedSemaphore(Semaphore):
|
||||
def __init__(self, value: int = 1, *, ctx: BaseContext) -> None: ...
|
||||
|
||||
@@ -390,14 +390,13 @@ class Cursor(Iterator[Any]):
|
||||
def __iter__(self) -> Self: ...
|
||||
def __next__(self) -> Any: ...
|
||||
|
||||
class DataError(DatabaseError): ...
|
||||
class DatabaseError(Error): ...
|
||||
|
||||
class Error(Exception):
|
||||
if sys.version_info >= (3, 11):
|
||||
sqlite_errorcode: int
|
||||
sqlite_errorname: str
|
||||
|
||||
class DatabaseError(Error): ...
|
||||
class DataError(DatabaseError): ...
|
||||
class IntegrityError(DatabaseError): ...
|
||||
class InterfaceError(Error): ...
|
||||
class InternalError(DatabaseError): ...
|
||||
|
||||
Reference in New Issue
Block a user