mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Replace aliases by builtins.* in uuid (#10422)
These aliases were used because the class has properties called `int` and `bytes`. I think it is better to use the shadowed types from the builtins module. This should not change anything from the type checking side but it improves the IDE experience[^1]. [^1]: I was using uuid recently and the aliases showed up in vscode, I thought they were uuid special types and had to look in the stub to know what they are.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import builtins
|
||||
import sys
|
||||
from _typeshed import Unused
|
||||
from enum import Enum
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
# Because UUID has properties called int and bytes we need to rename these temporarily.
|
||||
_Int: TypeAlias = int
|
||||
_Bytes: TypeAlias = bytes
|
||||
_FieldsType: TypeAlias = tuple[int, int, int, int, int, int]
|
||||
|
||||
class SafeUUID(Enum):
|
||||
@@ -17,49 +15,49 @@ class UUID:
|
||||
def __init__(
|
||||
self,
|
||||
hex: str | None = None,
|
||||
bytes: _Bytes | None = None,
|
||||
bytes_le: _Bytes | None = None,
|
||||
bytes: builtins.bytes | None = None,
|
||||
bytes_le: builtins.bytes | None = None,
|
||||
fields: _FieldsType | None = None,
|
||||
int: _Int | None = None,
|
||||
version: _Int | None = None,
|
||||
int: builtins.int | None = None,
|
||||
version: builtins.int | None = None,
|
||||
*,
|
||||
is_safe: SafeUUID = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def is_safe(self) -> SafeUUID: ...
|
||||
@property
|
||||
def bytes(self) -> _Bytes: ...
|
||||
def bytes(self) -> builtins.bytes: ...
|
||||
@property
|
||||
def bytes_le(self) -> _Bytes: ...
|
||||
def bytes_le(self) -> builtins.bytes: ...
|
||||
@property
|
||||
def clock_seq(self) -> _Int: ...
|
||||
def clock_seq(self) -> builtins.int: ...
|
||||
@property
|
||||
def clock_seq_hi_variant(self) -> _Int: ...
|
||||
def clock_seq_hi_variant(self) -> builtins.int: ...
|
||||
@property
|
||||
def clock_seq_low(self) -> _Int: ...
|
||||
def clock_seq_low(self) -> builtins.int: ...
|
||||
@property
|
||||
def fields(self) -> _FieldsType: ...
|
||||
@property
|
||||
def hex(self) -> str: ...
|
||||
@property
|
||||
def int(self) -> _Int: ...
|
||||
def int(self) -> builtins.int: ...
|
||||
@property
|
||||
def node(self) -> _Int: ...
|
||||
def node(self) -> builtins.int: ...
|
||||
@property
|
||||
def time(self) -> _Int: ...
|
||||
def time(self) -> builtins.int: ...
|
||||
@property
|
||||
def time_hi_version(self) -> _Int: ...
|
||||
def time_hi_version(self) -> builtins.int: ...
|
||||
@property
|
||||
def time_low(self) -> _Int: ...
|
||||
def time_low(self) -> builtins.int: ...
|
||||
@property
|
||||
def time_mid(self) -> _Int: ...
|
||||
def time_mid(self) -> builtins.int: ...
|
||||
@property
|
||||
def urn(self) -> str: ...
|
||||
@property
|
||||
def variant(self) -> str: ...
|
||||
@property
|
||||
def version(self) -> _Int | None: ...
|
||||
def __int__(self) -> _Int: ...
|
||||
def version(self) -> builtins.int | None: ...
|
||||
def __int__(self) -> builtins.int: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __lt__(self, other: UUID) -> bool: ...
|
||||
def __le__(self, other: UUID) -> bool: ...
|
||||
@@ -72,7 +70,7 @@ if sys.version_info >= (3, 9):
|
||||
else:
|
||||
def getnode(*, getters: Unused = None) -> int: ... # undocumented
|
||||
|
||||
def uuid1(node: _Int | None = None, clock_seq: _Int | None = None) -> UUID: ...
|
||||
def uuid1(node: int | None = None, clock_seq: int | None = None) -> UUID: ...
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
def uuid3(namespace: UUID, name: str | bytes) -> UUID: ...
|
||||
|
||||
Reference in New Issue
Block a user