diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 455f398..dc1ef36 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -44,7 +44,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 diff --git a/pyproject.toml b/pyproject.toml index 9027922..e0ebf72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ license = "MIT" readme = "README.md" authors = [{ name = "Kyle Barron", email = "kyle@developmentseed.org" }] requires-python = ">=3.9" -dependencies = [] +dependencies = ["typing-extensions; python_version < '3.12'"] keywords = [] classifiers = [ "Development Status :: 4 - Beta", diff --git a/src/obspec/_attributes.py b/src/obspec/_attributes.py index 783fc91..13be30b 100644 --- a/src/obspec/_attributes.py +++ b/src/obspec/_attributes.py @@ -1,17 +1,23 @@ from __future__ import annotations -from typing import Literal, TypeAlias +import sys +from typing import Literal, Union -Attribute: TypeAlias = ( +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias + +Attribute: TypeAlias = Union[ Literal[ "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Type", "Cache-Control", - ] - | str -) + ], + str, +] """Additional object attribute types. - `"Content-Disposition"`: Specifies how the object should be handled by a browser. diff --git a/src/obspec/_get.py b/src/obspec/_get.py index 301f712..083fa6f 100644 --- a/src/obspec/_get.py +++ b/src/obspec/_get.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Protocol, Self, TypedDict +from typing import TYPE_CHECKING, Protocol, TypedDict if TYPE_CHECKING: import sys @@ -10,6 +10,11 @@ from ._attributes import Attributes from ._meta import ObjectMeta + if sys.version_info >= (3, 11): + from typing import Self + else: + from typing_extensions import Self + if sys.version_info >= (3, 12): from collections.abc import Buffer else: diff --git a/src/obspec/_list.py b/src/obspec/_list.py index 061aab9..04e2d9b 100644 --- a/src/obspec/_list.py +++ b/src/obspec/_list.py @@ -1,19 +1,17 @@ from __future__ import annotations +import sys from collections.abc import Sequence -from typing import ( - Generic, - Literal, - Protocol, - Self, - TypedDict, - TypeVar, - overload, -) +from typing import Generic, Literal, Protocol, TypedDict, TypeVar, overload from ._meta import ObjectMeta from .arrow import ArrowArrayExportable, ArrowStreamExportable +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + ListChunkType_co = TypeVar( "ListChunkType_co", Sequence[ObjectMeta], diff --git a/src/obspec/_put.py b/src/obspec/_put.py index f8bdc00..c16a9db 100644 --- a/src/obspec/_put.py +++ b/src/obspec/_put.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import IO, TYPE_CHECKING, Literal, Protocol, TypeAlias, TypedDict +from typing import IO, TYPE_CHECKING, Literal, Protocol, TypedDict, Union if TYPE_CHECKING: import sys @@ -9,6 +9,11 @@ from ._attributes import Attributes + if sys.version_info >= (3, 10): + from typing import TypeAlias + else: + from typing_extensions import TypeAlias + if sys.version_info >= (3, 12): from collections.abc import Buffer else: @@ -32,7 +37,7 @@ class UpdateVersion(TypedDict, total=False): """A version indicator for the newly created object.""" -PutMode: TypeAlias = Literal["create", "overwrite"] | UpdateVersion +PutMode: TypeAlias = Union[Literal["create", "overwrite"], UpdateVersion] """Configure preconditions for the put operation There are three modes: diff --git a/uv.lock b/uv.lock index ac329bc..7d03ca3 100644 --- a/uv.lock +++ b/uv.lock @@ -918,6 +918,9 @@ wheels = [ name = "obspec" version = "0.1.0b4" source = { editable = "." } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.12'" }, +] [package.dev-dependencies] dev = [ @@ -936,6 +939,7 @@ dev = [ ] [package.metadata] +requires-dist = [{ name = "typing-extensions", marker = "python_full_version < '3.12'" }] [package.metadata.requires-dev] dev = [