From edfba0068908a349c08bc84a0b27f3eddfd1d8fb Mon Sep 17 00:00:00 2001 From: Trim21 Date: Mon, 9 Sep 2024 19:17:04 +0800 Subject: [PATCH] typing --- python/uuid_utils/__init__.pyi | 47 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/python/uuid_utils/__init__.pyi b/python/uuid_utils/__init__.pyi index 309a3ad..7568cfe 100644 --- a/python/uuid_utils/__init__.pyi +++ b/python/uuid_utils/__init__.pyi @@ -1,3 +1,4 @@ +import builtins import sys from enum import Enum @@ -5,8 +6,6 @@ from _typeshed import Unused 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] __version__: str @@ -74,44 +73,44 @@ 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 timestamp(self) -> _Int: + def timestamp(self) -> builtins.int: """Get UUID timestamp milliseconds since epoch. Only works for UUID versions 1, 6 and 7, otherwise raises ValueError.""" ... @@ -121,8 +120,8 @@ class UUID: @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: ... @@ -135,7 +134,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: """Generate a UUID from a host ID, sequence number, and the current time. If 'node' is not given, getnode() is used to obtain the hardware address. If 'clock_seq' is given, it is used as the sequence number; @@ -165,7 +164,7 @@ else: ... def uuid6( - node: _Int | None = None, timestamp: _Int | None = None, nanos: _Int | None = None + node: int | None = None, timestamp: int | None = None, nanos: int | None = None ) -> UUID: """Generate a version 6 UUID using the given timestamp and a host ID. This is similar to version 1 UUIDs, @@ -173,11 +172,11 @@ def uuid6( """ ... -def uuid7(timestamp: _Int | None = None, nanos: _Int | None = None) -> UUID: +def uuid7(timestamp: int | None = None, nanos: int | None = None) -> UUID: """Generate a version 7 UUID using a time value and random bytes.""" ... -def uuid8(bytes: _Bytes) -> UUID: +def uuid8(bytes: bytes) -> UUID: """Generate a custom UUID comprised almost entirely of user-supplied bytes.""" ...