@@ -3,7 +3,7 @@ import sys
33from _typeshed import BytesPath , FileDescriptorOrPath , StrOrBytesPath , StrPath , SupportsRichComparisonT
44from collections .abc import Sequence
55from typing import Literal , NewType , overload
6- from typing_extensions import LiteralString
6+ from typing_extensions import LiteralString , deprecated
77
88__all__ = [
99 "commonprefix" ,
@@ -23,22 +23,42 @@ if sys.version_info >= (3, 12):
2323 __all__ += ["islink" ]
2424if sys .version_info >= (3 , 13 ):
2525 __all__ += ["isjunction" , "isdevdrive" , "lexists" ]
26+ if sys .version_info >= (3 , 15 ):
27+ __all__ += ["ALL_BUT_LAST" ]
2628
2729# All overloads can return empty string. Ideally, Literal[""] would be a valid
2830# Iterable[T], so that list[T] | Literal[""] could be used as a return
2931# type. But because this only works when T is str, we need Sequence[T] instead.
30- @overload
31- def commonprefix (m : Sequence [LiteralString ]) -> LiteralString : ...
32- @overload
33- def commonprefix (m : Sequence [StrPath ]) -> str : ...
34- @overload
35- def commonprefix (m : Sequence [BytesPath ]) -> bytes | Literal ["" ]: ...
36- @overload
37- def commonprefix (m : Sequence [list [SupportsRichComparisonT ]]) -> Sequence [SupportsRichComparisonT ]: ...
38- @overload
39- def commonprefix (m : Sequence [tuple [SupportsRichComparisonT , ...]]) -> Sequence [SupportsRichComparisonT ]: ...
32+ if sys .version_info >= (3 , 15 ):
33+ @overload
34+ @deprecated ("Deprecated since Python 3.15; use os.path.commonpath() for path prefixes." )
35+ def commonprefix (m : Sequence [LiteralString ], / ) -> LiteralString : ...
36+ @overload
37+ @deprecated ("Deprecated since Python 3.15; use os.path.commonpath() for path prefixes." )
38+ def commonprefix (m : Sequence [StrPath ], / ) -> str : ...
39+ @overload
40+ @deprecated ("Deprecated since Python 3.15; use os.path.commonpath() for path prefixes." )
41+ def commonprefix (m : Sequence [BytesPath ], / ) -> bytes | Literal ["" ]: ...
42+ @overload
43+ @deprecated ("Deprecated since Python 3.15; use os.path.commonpath() for path prefixes." )
44+ def commonprefix (m : Sequence [list [SupportsRichComparisonT ]], / ) -> Sequence [SupportsRichComparisonT ]: ...
45+ @overload
46+ @deprecated ("Deprecated since Python 3.15; use os.path.commonpath() for path prefixes." )
47+ def commonprefix (m : Sequence [tuple [SupportsRichComparisonT , ...]], / ) -> Sequence [SupportsRichComparisonT ]: ...
48+
49+ else :
50+ @overload
51+ def commonprefix (m : Sequence [LiteralString ]) -> LiteralString : ...
52+ @overload
53+ def commonprefix (m : Sequence [StrPath ]) -> str : ...
54+ @overload
55+ def commonprefix (m : Sequence [BytesPath ]) -> bytes | Literal ["" ]: ...
56+ @overload
57+ def commonprefix (m : Sequence [list [SupportsRichComparisonT ]]) -> Sequence [SupportsRichComparisonT ]: ...
58+ @overload
59+ def commonprefix (m : Sequence [tuple [SupportsRichComparisonT , ...]]) -> Sequence [SupportsRichComparisonT ]: ...
60+
4061def exists (path : FileDescriptorOrPath ) -> bool : ...
41- def getsize (filename : FileDescriptorOrPath ) -> int : ...
4262def isfile (path : FileDescriptorOrPath ) -> bool : ...
4363def isdir (s : FileDescriptorOrPath ) -> bool : ...
4464
@@ -47,12 +67,23 @@ if sys.version_info >= (3, 12):
4767
4868# These return float if os.stat_float_times() == True,
4969# but int is a subclass of float.
50- def getatime (filename : FileDescriptorOrPath ) -> float : ...
51- def getmtime (filename : FileDescriptorOrPath ) -> float : ...
52- def getctime (filename : FileDescriptorOrPath ) -> float : ...
53- def samefile (f1 : FileDescriptorOrPath , f2 : FileDescriptorOrPath ) -> bool : ...
5470def sameopenfile (fp1 : int , fp2 : int ) -> bool : ...
55- def samestat (s1 : os .stat_result , s2 : os .stat_result ) -> bool : ...
71+
72+ if sys .version_info >= (3 , 15 ):
73+ def getsize (filename : FileDescriptorOrPath , / ) -> int : ...
74+ def getatime (filename : FileDescriptorOrPath , / ) -> float : ...
75+ def getmtime (filename : FileDescriptorOrPath , / ) -> float : ...
76+ def getctime (filename : FileDescriptorOrPath , / ) -> float : ...
77+ def samefile (f1 : FileDescriptorOrPath , f2 : FileDescriptorOrPath , / ) -> bool : ...
78+ def samestat (s1 : os .stat_result , s2 : os .stat_result , / ) -> bool : ...
79+
80+ else :
81+ def getsize (filename : FileDescriptorOrPath ) -> int : ...
82+ def getatime (filename : FileDescriptorOrPath ) -> float : ...
83+ def getmtime (filename : FileDescriptorOrPath ) -> float : ...
84+ def getctime (filename : FileDescriptorOrPath ) -> float : ...
85+ def samefile (f1 : FileDescriptorOrPath , f2 : FileDescriptorOrPath ) -> bool : ...
86+ def samestat (s1 : os .stat_result , s2 : os .stat_result ) -> bool : ...
5687
5788if sys .version_info >= (3 , 13 ):
5889 def isjunction (path : StrOrBytesPath ) -> bool : ...
@@ -62,3 +93,7 @@ if sys.version_info >= (3, 13):
6293# Added in Python 3.9.23, 3.10.18, 3.11.13, 3.12.11, 3.13.4
6394_AllowMissingType = NewType ("_AllowMissingType" , object )
6495ALLOW_MISSING : _AllowMissingType
96+
97+ if sys .version_info >= (3 , 15 ):
98+ _AllButLastType = NewType ("_AllButLastType" , object )
99+ ALL_BUT_LAST : _AllButLastType
0 commit comments