Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions stdlib/2and3/uuid.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
# Stubs for uuid

import sys
from enum import Enum
from typing import Tuple, Optional, Any, Text

# Because UUID has properties called int and bytes we need to rename these temporarily.
_Int = int
_Bytes = bytes
_FieldsType = Tuple[int, int, int, int, int, int]

if sys.version_info >= (3, 7):
class SafeUUID(Enum):
safe: int
unsafe: int
unknown: None


class UUID:
def __init__(self, hex: Optional[Text] = ...,
bytes: Optional[_Bytes] = ...,
bytes_le: Optional[_Bytes] = ...,
fields: Optional[_FieldsType] = ...,
int: Optional[_Int] = ...,
version: Optional[_Int] = ...) -> None: ...
if sys.version_info >= (3, 7):
def __init__(self, hex: Optional[Text] = ...,
bytes: Optional[_Bytes] = ...,
bytes_le: Optional[_Bytes] = ...,
fields: Optional[_FieldsType] = ...,
int: Optional[_Int] = ...,
version: Optional[_Int] = ...,
*,
is_safe: SafeUUID = ...) -> None: ...
@property
def is_safe(self) -> SafeUUID: ...
else:
def __init__(self, hex: Optional[Text] = ...,
bytes: Optional[_Bytes] = ...,
bytes_le: Optional[_Bytes] = ...,
fields: Optional[_FieldsType] = ...,
int: Optional[_Int] = ...,
version: Optional[_Int] = ...) -> None: ...
@property
def bytes(self) -> _Bytes: ...
@property
Expand Down Expand Up @@ -74,7 +94,7 @@ class UUID:
def get_version(self) -> Optional[_Int]: ...
def __cmp__(self, other: Any) -> _Int: ...

def getnode() -> int: ...
def getnode(*, getters: None = ...) -> int: ... # getters is undocumented (and unused)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it got removed from CPython master, maybe we should also just omit it from typeshed? There's no reason for anyone to actually use the argument.

def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ...
def uuid3(namespace: UUID, name: str) -> UUID: ...
def uuid4() -> UUID: ...
Expand Down