Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@
UnsupportedOperation = NotImplementedError
"""Raised when an unsupported operation is called on a path object."""

if TYPE_CHECKING:
import upath.implementations as _uimpl

if sys.version_info >= (3, 11):
from typing import Self
else:
if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
from pydantic import GetCoreSchemaHandler
from pydantic_core.core_schema import CoreSchema

import upath.implementations as _uimpl

_MT = TypeVar("_MT")
_WT = TypeVar("_WT", bound="WritablePath")

_WT = TypeVar("_WT", bound="WritablePath")

__all__ = [
"UPath",
Expand Down
11 changes: 7 additions & 4 deletions upath/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@
from upath.types import UPathParser
from upath.types import WritablePathLike

if TYPE_CHECKING:
if sys.version_info > (3, 11):
from typing import Self
else:
if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
from pydantic import GetCoreSchemaHandler
from pydantic_core.core_schema import CoreSchema

Expand Down
8 changes: 4 additions & 4 deletions upath/implementations/cached.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
from __future__ import annotations

import sys
from collections.abc import Mapping
from types import MappingProxyType
from typing import TYPE_CHECKING
from typing import Any

from fsspec import AbstractFileSystem

from upath.core import UPath
from upath.types import JoinablePathLike

if TYPE_CHECKING:
from collections.abc import Mapping
from typing import Any
from typing import Literal

if sys.version_info >= (3, 11):
from typing import Unpack
else:
from typing_extensions import Unpack

from fsspec import AbstractFileSystem

from upath._chain import FSSpecChainParser
from upath.types.storage_options import SimpleCacheStorageOptions

Expand Down
33 changes: 16 additions & 17 deletions upath/implementations/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,35 @@
import sys
from collections.abc import Iterator
from collections.abc import Sequence
from typing import TYPE_CHECKING
from typing import Any
from typing import Literal
from typing import TypeVar
from typing import overload

from upath import UnsupportedOperation
from upath._chain import DEFAULT_CHAIN_PARSER
from upath._chain import FSSpecChainParser
from upath._flavour import upath_strip_protocol
from upath.core import UPath
from upath.types import JoinablePathLike
from upath.types import SupportsPathLike
from upath.types import WritablePath

if TYPE_CHECKING:
from typing import Literal
from typing import TypeVar

if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
from upath.types.storage_options import AzureStorageOptions
from upath.types.storage_options import GCSStorageOptions
from upath.types.storage_options import HfStorageOptions
from upath.types.storage_options import S3StorageOptions

if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
try:
from typing_extensions import Self
from typing_extensions import Unpack
except ImportError: # only needed for resolving annotations at runtime
pass

from upath._chain import FSSpecChainParser
from upath.types.storage_options import AzureStorageOptions
from upath.types.storage_options import GCSStorageOptions
from upath.types.storage_options import HfStorageOptions
from upath.types.storage_options import S3StorageOptions

_WT = TypeVar("_WT", bound="WritablePath")
_WT = TypeVar("_WT", bound="WritablePath")

__all__ = [
"CloudPath",
Expand Down
10 changes: 8 additions & 2 deletions upath/implementations/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@
from upath.core import UPath
from upath.types import JoinablePathLike

if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
from typing import Literal

if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
from typing_extensions import Self
from typing_extensions import Unpack

from upath._chain import FSSpecChainParser
Expand Down
14 changes: 10 additions & 4 deletions upath/implementations/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@
import sys
from ftplib import error_perm as FTPPermanentError # nosec B402
from typing import TYPE_CHECKING
from typing import Any

from upath.core import UPath
from upath.types import UNSET_DEFAULT
from upath.types import JoinablePathLike
from upath.types import WritablePathLike

if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
from typing import Any
from typing import Literal

if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
from typing_extensions import Self
from typing_extensions import Unpack

from upath._chain import FSSpecChainParser
from upath.types import WritablePathLike
from upath.types.storage_options import FTPStorageOptions

__all__ = ["FTPPath"]
Expand Down
10 changes: 8 additions & 2 deletions upath/implementations/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
from upath.types import JoinablePathLike
from upath.types import StatResultType

if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
from typing import Literal

if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
from typing_extensions import Self
from typing_extensions import Unpack

from upath._chain import FSSpecChainParser
Expand Down
21 changes: 13 additions & 8 deletions upath/implementations/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
import warnings
from collections.abc import Iterator
from collections.abc import Sequence
from typing import IO
from typing import TYPE_CHECKING
from typing import Any
from typing import BinaryIO
from typing import Callable
from typing import Literal
from typing import TextIO
from typing import TypeVar
from typing import overload
from urllib.parse import SplitResult
from urllib.parse import unquote_to_bytes
Expand All @@ -36,25 +40,26 @@
from upath.types import WritablePath
from upath.types import WritablePathLike

if TYPE_CHECKING:
from typing import IO
from typing import BinaryIO
from typing import TextIO
from typing import TypeVar
if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
from typing_extensions import Self
from typing_extensions import Unpack

from pydantic import GetCoreSchemaHandler
from pydantic_core.core_schema import CoreSchema

from upath.types.storage_options import FileStorageOptions

_WT = TypeVar("_WT", bound="WritablePath")
_WT = TypeVar("_WT", bound="WritablePath")

__all__ = [
"LocalPath",
Expand Down
10 changes: 8 additions & 2 deletions upath/implementations/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@
from upath.types import JoinablePathLike
from upath.types import WritablePathLike

if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
from typing import Literal

if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
from typing_extensions import Self
from typing_extensions import Unpack

from upath._chain import FSSpecChainParser
Expand Down
12 changes: 9 additions & 3 deletions upath/implementations/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import stat
import sys
import warnings
from collections.abc import Iterator
from typing import TYPE_CHECKING

from upath._stat import UPathStatResult
Expand All @@ -11,15 +12,20 @@
from upath.types import JoinablePathLike
from upath.types import StatResultType

if sys.version_info >= (3, 11):
from typing import Self
else:
try:
from typing_extensions import Self
except ImportError: # only needed for resolving annotations at runtime
pass

if TYPE_CHECKING:
from collections.abc import Iterator
from typing import Literal

if sys.version_info >= (3, 11):
from typing import Self
from typing import Unpack
else:
from typing_extensions import Self
from typing_extensions import Unpack

from upath._chain import FSSpecChainParser
Expand Down
Loading
Loading