From 106e2321708a8f491f2be716181b397a8d5263a9 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Wed, 2 Oct 2024 13:02:09 -0400 Subject: [PATCH 1/3] DEP: Ensure typing_extension is dependency for earlier python versions --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 54b638e..b6f61f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ maintainers = [ requires-python = ">=3.8" dependencies = [ "fsspec >=2022.1.0,!=2024.3.1", + "typing_extensions; python_version<'3.11'", ] classifiers = [ "Programming Language :: Python :: 3", From 07744ad642b4e57c8c42af3376d5d32bfc76a79e Mon Sep 17 00:00:00 2001 From: mathiasg Date: Thu, 3 Oct 2024 10:46:23 -0400 Subject: [PATCH 2/3] RF: Guard type definition to explicit type checking, add typing_extensions to [dev] extra --- pyproject.toml | 2 +- upath/core.py | 10 +++++----- upath/implementations/sftp.py | 10 ++++++---- upath/implementations/smb.py | 10 ++++++---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b6f61f6..53a427e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ maintainers = [ requires-python = ">=3.8" dependencies = [ "fsspec >=2022.1.0,!=2024.3.1", - "typing_extensions; python_version<'3.11'", ] classifiers = [ "Programming Language :: Python :: 3", @@ -62,6 +61,7 @@ dev = [ "pydantic", "pydantic-settings", "smbprotocol", + "typing_extensions; python_version<'3.11'", ] [project.urls] diff --git a/upath/core.py b/upath/core.py index 2003fa9..2f3e818 100644 --- a/upath/core.py +++ b/upath/core.py @@ -19,11 +19,6 @@ from typing import overload from urllib.parse import urlsplit -if sys.version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self - from fsspec.registry import get_filesystem_class from fsspec.spec import AbstractFileSystem @@ -43,6 +38,11 @@ if TYPE_CHECKING: from urllib.parse import SplitResult + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self + __all__ = ["UPath"] diff --git a/upath/implementations/sftp.py b/upath/implementations/sftp.py index ed9b447..247b7d6 100644 --- a/upath/implementations/sftp.py +++ b/upath/implementations/sftp.py @@ -3,11 +3,13 @@ import sys from typing import Any from typing import Generator +from typing import TYPE_CHECKING -if sys.version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self +if TYPE_CHECKING: + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self from upath import UPath diff --git a/upath/implementations/smb.py b/upath/implementations/smb.py index f8505a2..cfd868d 100644 --- a/upath/implementations/smb.py +++ b/upath/implementations/smb.py @@ -4,11 +4,13 @@ import sys import warnings from typing import Any +from typing import TYPE_CHECKING -if sys.version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self +if TYPE_CHECKING: + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self import smbprotocol.exceptions From eda3545d6f9d4dab17b8f6c31e3a12af9d4154e5 Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Thu, 3 Oct 2024 22:17:23 +0200 Subject: [PATCH 3/3] fix linting --- upath/implementations/sftp.py | 2 +- upath/implementations/smb.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/upath/implementations/sftp.py b/upath/implementations/sftp.py index 247b7d6..fe1511e 100644 --- a/upath/implementations/sftp.py +++ b/upath/implementations/sftp.py @@ -1,9 +1,9 @@ from __future__ import annotations import sys +from typing import TYPE_CHECKING from typing import Any from typing import Generator -from typing import TYPE_CHECKING if TYPE_CHECKING: if sys.version_info >= (3, 11): diff --git a/upath/implementations/smb.py b/upath/implementations/smb.py index cfd868d..492d738 100644 --- a/upath/implementations/smb.py +++ b/upath/implementations/smb.py @@ -3,8 +3,8 @@ import os import sys import warnings -from typing import Any from typing import TYPE_CHECKING +from typing import Any if TYPE_CHECKING: if sys.version_info >= (3, 11):