Skip to content

Commit 7da44b8

Browse files
authored
Merge pull request #21 from rbuffat/generalize_typeid_from_uuid_type
allow uuid.UUID in TypeID.from_uuid
2 parents d0208fc + 8c24cf9 commit 7da44b8

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

typeid/typeid.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Optional
33

44
import uuid6
5+
import uuid
56

67
from typeid import base32
78
from typeid.errors import InvalidTypeIDStringException
@@ -24,7 +25,7 @@ def from_string(cls, string: str):
2425
return cls(suffix=suffix, prefix=prefix)
2526

2627
@classmethod
27-
def from_uuid(cls, suffix: uuid6.UUID, prefix: Optional[str] = None):
28+
def from_uuid(cls, suffix: uuid.UUID, prefix: Optional[str] = None):
2829
suffix_str = _convert_uuid_to_b32(suffix)
2930
return cls(suffix=suffix_str, prefix=prefix)
3031

@@ -74,7 +75,7 @@ def from_string(string: str) -> TypeID:
7475
return TypeID.from_string(string=string)
7576

7677

77-
def from_uuid(suffix: uuid6.UUID, prefix: Optional[str] = None) -> TypeID:
78+
def from_uuid(suffix: uuid.UUID, prefix: Optional[str] = None) -> TypeID:
7879
warnings.warn("Consider TypeID.from_uuid instead.", DeprecationWarning)
7980
return TypeID.from_uuid(suffix=suffix, prefix=prefix)
8081

@@ -96,7 +97,7 @@ def get_prefix_and_suffix(string: str) -> tuple:
9697
return prefix, suffix
9798

9899

99-
def _convert_uuid_to_b32(uuid_instance: uuid6.UUID) -> str:
100+
def _convert_uuid_to_b32(uuid_instance: uuid.UUID) -> str:
100101
return base32.encode(list(uuid_instance.bytes))
101102

102103

0 commit comments

Comments
 (0)