Fix pathlib version conflict
This commit is contained in:
parent
d231505686
commit
7e01745d91
1 changed files with 12 additions and 1 deletions
|
@ -9,7 +9,7 @@ from pathlib import PosixPath as PosixPathBase
|
||||||
from pathlib import WindowsPath as WindowsPathBase
|
from pathlib import WindowsPath as WindowsPathBase
|
||||||
from platform import system
|
from platform import system
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from typing import Iterable
|
from typing import Callable, Iterable
|
||||||
|
|
||||||
_UMASK_LOCK = RLock()
|
_UMASK_LOCK = RLock()
|
||||||
_CODE_OSERROR_DIRECTORY_NOT_EMPTY = 66 if system() == 'FreeBSD' else 39
|
_CODE_OSERROR_DIRECTORY_NOT_EMPTY = 66 if system() == 'FreeBSD' else 39
|
||||||
|
@ -19,6 +19,17 @@ _LOGGER = getLogger(name=__name__)
|
||||||
class Path(PathBase):
|
class Path(PathBase):
|
||||||
'Extending the built-in `Path`.'
|
'Extending the built-in `Path`.'
|
||||||
|
|
||||||
|
def __new__(cls, *args: str, **kwargs: str):
|
||||||
|
if cls is Path:
|
||||||
|
cls = WindowsPath if os_name == 'nt' else PosixPath
|
||||||
|
if hasattr(cls, '_from_parts'):
|
||||||
|
cls._from_parts: Callable[[Iterable[str]], WindowsPath | PosixPath]
|
||||||
|
# version < 3.12
|
||||||
|
return cls._from_parts(args)
|
||||||
|
else:
|
||||||
|
# 3.12 on
|
||||||
|
return object.__new__(cls)
|
||||||
|
|
||||||
def _ensure_parentdirs_inner(
|
def _ensure_parentdirs_inner(
|
||||||
self, relative_path: Path, mode: int | None = None,
|
self, relative_path: Path, mode: int | None = None,
|
||||||
uid: int | None = None, gid: int | None = None) -> Path:
|
uid: int | None = None, gid: int | None = None) -> Path:
|
||||||
|
|
Loading…
Reference in a new issue