mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
tmp_dir: fix object initialization for Python 3.12 (#10105)
This commit is contained in:
+14
-10
@@ -70,16 +70,20 @@ class TmpDir(pathlib.Path):
|
|||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls is TmpDir:
|
if cls is TmpDir:
|
||||||
cls = WindowsTmpDir if os.name == "nt" else PosixTmpDir
|
cls = WindowsTmpDir if os.name == "nt" else PosixTmpDir
|
||||||
# init parameter and `_init` method has been removed in Python 3.10.
|
|
||||||
kw = {"init": False} if sys.version_info < (3, 10) else {}
|
if sys.version_info >= (3, 12):
|
||||||
self = cls._from_parts(args, **kw) # type: ignore[attr-defined]
|
return object.__new__(cls)
|
||||||
if not self._flavour.is_supported:
|
else: # noqa: RET505
|
||||||
raise NotImplementedError(
|
# init parameter and `_init` method has been removed in Python 3.10.
|
||||||
f"cannot instantiate {cls.__name__!r} on your system"
|
kw = {"init": False} if sys.version_info < (3, 10) else {}
|
||||||
)
|
self = cls._from_parts(args, **kw) # type: ignore[attr-defined]
|
||||||
if sys.version_info < (3, 10):
|
if not self._flavour.is_supported:
|
||||||
self._init()
|
raise NotImplementedError(
|
||||||
return self
|
f"cannot instantiate {cls.__name__!r} on your system"
|
||||||
|
)
|
||||||
|
if sys.version_info < (3, 10):
|
||||||
|
self._init()
|
||||||
|
return self
|
||||||
|
|
||||||
def init(self, *, scm=False, dvc=False, subdir=False):
|
def init(self, *, scm=False, dvc=False, subdir=False):
|
||||||
from dvc.repo import Repo
|
from dvc.repo import Repo
|
||||||
|
|||||||
Reference in New Issue
Block a user