Skip to content

Commit

Permalink
upath.implementations.local: Path.__init__ quirks on python 3.8-3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-- committed Sep 3, 2024
1 parent 36068bf commit 50bd74e
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions upath/implementations/local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import sys
from pathlib import PosixPath
from pathlib import WindowsPath
from typing import Any
Expand Down Expand Up @@ -77,18 +78,21 @@ def __new__(
) -> Self:
if not compatible_protocol("", path, *paths):
raise ValueError("can't combine incompatible UPath protocols")
return super().__new__(cls, str(path), *map(str, paths))

def __init__(
self,
path: UPathLike,
*paths: UPathLike,
protocol: str | None = None,
**storage_options: Any,
) -> None:
super().__init__(self, str(path), *map(str, paths))
self._protocol = ""
self._storage_options = {}
obj = super().__new__(cls, str(path), *map(str, paths))
obj._protocol = ""
obj._storage_options = {}
return obj

if sys.version_info >= (3, 12):

def __init__(
self,
path: UPathLike,
*paths: UPathLike,
protocol: str | None = None,
**storage_options: Any,
) -> None:
super().__init__(str(path), *map(str, paths))

protocol = UPath.protocol
storage_options = UPath.storage_options
Expand Down Expand Up @@ -118,18 +122,21 @@ def __new__(
) -> Self:
if not compatible_protocol("", path, *paths):
raise ValueError("can't combine incompatible UPath protocols")
return super().__new__(cls, str(path), *map(str, paths))

def __init__(
self,
path: UPathLike,
*paths: UPathLike,
protocol: str | None = None,
**storage_options: Any,
) -> None:
super().__init__(self, str(path), *map(str, paths))
self._protocol = ""
self._storage_options = {}
obj = super().__new__(cls, str(path), *map(str, paths))
obj._protocol = ""
obj._storage_options = {}
return obj

if sys.version_info >= (3, 12):

def __init__(
self,
path: UPathLike,
*paths: UPathLike,
protocol: str | None = None,
**storage_options: Any,
) -> None:
super().__init__(str(path), *map(str, paths))

protocol = UPath.protocol
storage_options = UPath.storage_options
Expand Down

0 comments on commit 50bd74e

Please sign in to comment.