From 695644807e05c87bf874771890afebcd15a32080 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Wed, 5 Feb 2020 04:04:49 -0800 Subject: [PATCH] uuid: add is_safe, Safe UUID (#3715) * uuid: add is_safe, SafeUUID * uuid: add useless parameter --- stdlib/2and3/uuid.pyi | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/stdlib/2and3/uuid.pyi b/stdlib/2and3/uuid.pyi index 9c009d921..cfdcc1ebd 100644 --- a/stdlib/2and3/uuid.pyi +++ b/stdlib/2and3/uuid.pyi @@ -1,6 +1,7 @@ # 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. @@ -8,13 +9,32 @@ _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 @@ -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) def uuid1(node: Optional[_Int] = ..., clock_seq: Optional[_Int] = ...) -> UUID: ... def uuid3(namespace: UUID, name: str) -> UUID: ... def uuid4() -> UUID: ...