88from typeid .errors import InvalidTypeIDStringException
99from typeid .validation import validate_prefix , validate_suffix
1010
11- PrefixT = TypeVar ("PrefixT" , bound = Optional [ str ] )
11+ PrefixT = TypeVar ("PrefixT" , bound = str )
1212
1313
1414class TypeID (Generic [PrefixT ]):
15- def __init__ (self , prefix : PrefixT = None , suffix : Optional [str ] = None ) -> None :
15+ def __init__ (self , prefix : Optional [ PrefixT ] = None , suffix : Optional [str ] = None ) -> None :
1616 suffix = _convert_uuid_to_b32 (uuid6 .uuid7 ()) if not suffix else suffix
1717 validate_suffix (suffix = suffix )
18+
1819 if prefix is not None :
1920 validate_prefix (prefix = prefix )
2021
21- self ._prefix = prefix or ""
22- self ._suffix = suffix
22+ self ._prefix : Optional [ PrefixT ] = prefix
23+ self ._suffix : str = suffix
2324
2425 @classmethod
25- def from_string (cls , string : str ):
26+ def from_string (cls , string : str ) -> "TypeID" :
2627 prefix , suffix = get_prefix_and_suffix (string = string )
2728 return cls (suffix = suffix , prefix = prefix )
2829
2930 @classmethod
30- def from_uuid (cls , suffix : uuid .UUID , prefix : Optional [str ] = None ):
31+ def from_uuid (cls , suffix : uuid .UUID , prefix : Optional [PrefixT ] = None ) -> "TypeID" :
3132 suffix_str = _convert_uuid_to_b32 (suffix )
3233 return cls (suffix = suffix_str , prefix = prefix )
3334
@@ -37,7 +38,7 @@ def suffix(self) -> str:
3738
3839 @property
3940 def prefix (self ) -> str :
40- return self ._prefix
41+ return self ._prefix or ""
4142
4243 @property
4344 def uuid (self ) -> uuid6 .UUID :
0 commit comments