File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed
Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change 11import os
22import pathlib
33import posixpath
4+ import sys
45from typing import Callable , ClassVar
56from urllib .parse import urlparse
67
@@ -27,12 +28,13 @@ class PathInfo(pathlib.PurePath, _BasePath):
2728 __slots__ = ()
2829 scheme = "local"
2930
30- def __new__ (cls , * args ):
31- # Construct a proper subclass depending on current os
32- if cls is PathInfo :
33- cls = WindowsPathInfo if os .name == "nt" else PosixPathInfo
31+ if sys .version_info < (3 , 12 ):
3432
35- return cls ._from_parts (args ) # type: ignore[attr-defined]
33+ def __new__ (cls , * args ):
34+ if cls is PathInfo :
35+ cls = WindowsPathInfo if os .name == "nt" else PosixPathInfo
36+
37+ return cls ._from_parts (args ) # type: ignore[attr-defined]
3638
3739 def as_posix (self ):
3840 f = self ._flavour # type: ignore[attr-defined]
@@ -67,7 +69,7 @@ def relpath(self, other):
6769
6870 def isin (self , other ):
6971 if isinstance (other , (str , bytes )):
70- other = self .__class__ (other )
72+ other = self .__class__ (other ) # type: ignore[arg-type]
7173 elif self .__class__ != other .__class__ :
7274 return False
7375 # Use cached casefolded parts to compare paths
Original file line number Diff line number Diff line change @@ -67,13 +67,12 @@ def url(self):
6767 def config (self ):
6868 return {"url" : self .url }
6969
70- def __new__ (cls , * args , ** kwargs ):
71- if cls is TmpDir :
72- cls = WindowsTmpDir if os .name == "nt" else PosixTmpDir
70+ if sys .version_info < (3 , 12 ):
71+
72+ def __new__ (cls , * args , ** kwargs ):
73+ if cls is TmpDir :
74+ cls = WindowsTmpDir if os .name == "nt" else PosixTmpDir
7375
74- if sys .version_info >= (3 , 12 ):
75- return object .__new__ (cls )
76- else : # noqa: RET505
7776 # init parameter and `_init` method has been removed in Python 3.10.
7877 kw = {"init" : False } if sys .version_info < (3 , 10 ) else {}
7978 self = cls ._from_parts (args , ** kw ) # type: ignore[attr-defined]
You can’t perform that action at this time.
0 commit comments