Skip to content

allow uuid.UUID in TypeID.from_uuid #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions typeid/typeid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Optional

import uuid6
import uuid

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

@classmethod
def from_uuid(cls, suffix: uuid6.UUID, prefix: Optional[str] = None):
def from_uuid(cls, suffix: uuid.UUID, prefix: Optional[str] = None):
suffix_str = _convert_uuid_to_b32(suffix)
return cls(suffix=suffix_str, prefix=prefix)

Expand Down Expand Up @@ -74,7 +75,7 @@ def from_string(string: str) -> TypeID:
return TypeID.from_string(string=string)


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

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


def _convert_uuid_to_b32(uuid_instance: uuid6.UUID) -> str:
def _convert_uuid_to_b32(uuid_instance: uuid.UUID) -> str:
return base32.encode(list(uuid_instance.bytes))


Expand Down