3333
3434PY_311_OR_HIGHER = sys .version_info >= (3 , 11 , 0 )
3535PY_312_OR_HIGHER = sys .version_info >= (3 , 12 , 0 )
36+ PY_313_OR_HIGHER = sys .version_info >= (3 , 13 , 0 )
3637
3738TYPE_POSIX = 0
3839TYPE_WINDOWS = 1
@@ -600,12 +601,18 @@ def _unpack(cls, data):
600601 return data
601602
602603
603- def _is_posixlike_path (path : Any ):
604- return isinstance (path , pathlib .PurePath ) and "\\ " not in (path ._flavour .sep , path ._flavour .altsep )
604+ def _is_posixlike_path (path : Any ) -> bool :
605+ if isinstance (path , pathlib .PurePath ):
606+ obj = getattr (path , "parser" , None ) or path ._flavour
607+ return "\\ " not in (obj .sep , obj .altsep )
608+ return False
605609
606610
607- def _is_windowslike_path (path : Any ):
608- return isinstance (path , pathlib .PurePath ) and "\\ " in (path ._flavour .sep , path ._flavour .altsep )
611+ def _is_windowslike_path (path : Any ) -> bool :
612+ if isinstance (path , pathlib .PurePath ):
613+ obj = getattr (path , "parser" , None ) or path ._flavour
614+ return "\\ " in (obj .sep , obj .altsep )
615+ return False
609616
610617
611618class path (pathlib .PurePath , FieldType ):
@@ -684,17 +691,17 @@ def __repr__(self) -> str:
684691 return repr (str (self ))
685692
686693 @property
687- def parent (self ):
694+ def parent (self ) -> path :
688695 if self ._empty_path :
689696 return self
690697 return super ().parent
691698
692- def _pack (self ):
699+ def _pack (self ) -> tuple [ str , int ] :
693700 path_type = TYPE_WINDOWS if isinstance (self , windows_path ) else TYPE_POSIX
694701 return (str (self ), path_type )
695702
696703 @classmethod
697- def _unpack (cls , data : tuple [str , str ]):
704+ def _unpack (cls , data : tuple [str , str ]) -> posix_path | windows_path :
698705 path_ , path_type = data
699706 if path_type == TYPE_POSIX :
700707 return posix_path (path_ )
@@ -705,12 +712,12 @@ def _unpack(cls, data: tuple[str, str]):
705712 return posix_path (path_ )
706713
707714 @classmethod
708- def from_posix (cls , path_ : str ):
715+ def from_posix (cls , path_ : str ) -> posix_path :
709716 """Initialize a path instance from a posix path string using / as a separator."""
710717 return posix_path (path_ )
711718
712719 @classmethod
713- def from_windows (cls , path_ : str ):
720+ def from_windows (cls , path_ : str ) -> windows_path :
714721 """Initialize a path instance from a windows path string using \\ or / as a separator."""
715722 return windows_path (path_ )
716723
0 commit comments