Skip to content

Commit

Permalink
Drop support for Python 3.8 and 3.9 (#142)
Browse files Browse the repository at this point in the history
Because of [NEP29](https://numpy.org/neps/nep-0029-deprecation_policy) NumPy only supports ≥3.10 now.

Also, Zarr, NetworkX, and ([soon](pydata/xarray#8937)) Xarray will support only ≥3.10.
  • Loading branch information
basnijholt authored Jun 2, 2024
1 parent 8a9b113 commit 2e4c272
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 94 deletions.
5 changes: 4 additions & 1 deletion .github/update-environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

from __future__ import annotations

from typing import Iterable
from typing import TYPE_CHECKING

import tomllib

if TYPE_CHECKING:
from collections.abc import Iterable

PIP_ONLY_DEPS: set[str] = set()


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
with:
Expand Down
1 change: 0 additions & 1 deletion docs/environment-sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies:
- networkx
- psutil
- versioningit
- typing_extensions
- cloudpickle
- numpy
# optional-dependencies: xarray
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies:
- networkx
- psutil
- versioningit
- typing_extensions
- cloudpickle
- numpy
# optional-dependencies: xarray
Expand Down
2 changes: 1 addition & 1 deletion pipefunc/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from contextlib import nullcontext, suppress
from multiprocessing import Manager
from pathlib import Path
from typing import TYPE_CHECKING, Any, Hashable
from typing import TYPE_CHECKING, Any

import cloudpickle

Expand Down
16 changes: 3 additions & 13 deletions pipefunc/_pipefunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import functools
import inspect
import os
import sys
from typing import TYPE_CHECKING, Any, Generic, Tuple, TypeVar, Union
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Generic, TypeAlias, TypeVar, Union

import cloudpickle

Expand All @@ -27,22 +27,12 @@
from pipefunc.lazy import evaluate_lazy
from pipefunc.map._mapspec import MapSpec

if sys.version_info < (3, 9): # pragma: no cover
from typing import Callable
else:
from collections.abc import Callable

if TYPE_CHECKING:
from pathlib import Path

if sys.version_info < (3, 10): # pragma: no cover
from typing_extensions import TypeAlias
else:
from typing import TypeAlias


T = TypeVar("T", bound=Callable[..., Any])
_OUTPUT_TYPE: TypeAlias = Union[str, Tuple[str, ...]]
_OUTPUT_TYPE: TypeAlias = Union[str, tuple[str, ...]]
MAX_PARAMS_LEN = 15


Expand Down
18 changes: 4 additions & 14 deletions pipefunc/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import time
import warnings
from collections import defaultdict
from typing import TYPE_CHECKING, Any, Iterable, Literal, NamedTuple, Tuple, Union
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypeAlias, Union

import networkx as nx

Expand All @@ -44,7 +44,7 @@
from pipefunc.map._run import run

if TYPE_CHECKING:
import sys
from collections.abc import Callable, Iterable
from concurrent.futures import Executor
from pathlib import Path

Expand All @@ -53,19 +53,9 @@
from pipefunc._perf import ProfilingStats
from pipefunc.map._run import Result

if sys.version_info < (3, 10): # pragma: no cover
from typing_extensions import TypeAlias
else:
from typing import TypeAlias

if sys.version_info < (3, 9): # pragma: no cover
from typing import Callable
else:
from collections.abc import Callable


_OUTPUT_TYPE: TypeAlias = Union[str, Tuple[str, ...]]
_CACHE_KEY_TYPE: TypeAlias = Tuple[_OUTPUT_TYPE, Tuple[Tuple[str, Any], ...]]
_OUTPUT_TYPE: TypeAlias = Union[str, tuple[str, ...]]
_CACHE_KEY_TYPE: TypeAlias = tuple[_OUTPUT_TYPE, tuple[tuple[str, Any], ...]]


class _Function:
Expand Down
16 changes: 3 additions & 13 deletions pipefunc/_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,22 @@
import inspect
import warnings
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Tuple, Union
from typing import TYPE_CHECKING, Any, TypeAlias, Union

import networkx as nx

from pipefunc._utils import at_least_tuple

if TYPE_CHECKING:
import sys
from collections.abc import Callable

import networkx as nx

from pipefunc._pipefunc import PipeFunc
from pipefunc._pipeline import Pipeline

if sys.version_info < (3, 10): # pragma: no cover
from typing_extensions import TypeAlias
else:
from typing import TypeAlias

if sys.version_info < (3, 9): # pragma: no cover
from typing import Callable
else:
from collections.abc import Callable


_OUTPUT_TYPE: TypeAlias = Union[str, Tuple[str, ...]]
_OUTPUT_TYPE: TypeAlias = Union[str, tuple[str, ...]]


def _wrap_dict_to_tuple(
Expand Down
5 changes: 4 additions & 1 deletion pipefunc/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import sys
import warnings
from pathlib import Path
from typing import Any, Callable, Iterable
from typing import TYPE_CHECKING, Any

import cloudpickle
import numpy as np

if TYPE_CHECKING:
from collections.abc import Callable, Iterable


def at_least_tuple(x: Any) -> tuple[Any, ...]:
"""Convert x to a tuple if it is not already a tuple."""
Expand Down
10 changes: 3 additions & 7 deletions pipefunc/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
from __future__ import annotations

import contextlib
from typing import TYPE_CHECKING, Any, Generator, Iterable, NamedTuple
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any, NamedTuple

import networkx as nx

from pipefunc._cache import SimpleCache
from pipefunc._utils import format_function_call

if TYPE_CHECKING:
import sys

if sys.version_info < (3, 9): # pragma: no cover
from typing import Callable
else:
from collections.abc import Callable
from collections.abc import Callable, Generator


class _LazyFunction:
Expand Down
3 changes: 2 additions & 1 deletion pipefunc/map/_dictarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import itertools
import multiprocessing
from pathlib import Path
from typing import TYPE_CHECKING, Any, MutableMapping
from typing import TYPE_CHECKING, Any

import numpy as np

Expand All @@ -18,6 +18,7 @@
)

if TYPE_CHECKING:
from collections.abc import MutableMapping
from multiprocessing.managers import DictProxy


Expand Down
17 changes: 4 additions & 13 deletions pipefunc/map/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from contextlib import contextmanager
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Generator, NamedTuple, Sequence, Tuple, Union
from typing import TYPE_CHECKING, Any, NamedTuple, TypeAlias, Union

import numpy as np
import numpy.typing as npt
Expand All @@ -21,27 +21,18 @@
validate_consistent_axes,
)
from pipefunc.map._run_info import RunInfo, _external_shape, _internal_shape, _load_input
from pipefunc.map._storage_base import (
StorageBase,
_iterate_shape_indices,
_select_by_mask,
)
from pipefunc.map._storage_base import StorageBase, _iterate_shape_indices, _select_by_mask

if TYPE_CHECKING:
import sys
from collections.abc import Callable, Generator, Sequence

import xarray as xr

from pipefunc import PipeFunc, Pipeline
from pipefunc._pipeline import _Generations

if sys.version_info < (3, 10): # pragma: no cover
from typing_extensions import TypeAlias
else:
from typing import TypeAlias


_OUTPUT_TYPE: TypeAlias = Union[str, Tuple[str, ...]]
_OUTPUT_TYPE: TypeAlias = Union[str, tuple[str, ...]]


@dataclass
Expand Down
11 changes: 2 additions & 9 deletions pipefunc/map/_run_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,17 @@
import shutil
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any, NamedTuple, Tuple, Union
from typing import TYPE_CHECKING, Any, NamedTuple, TypeAlias, Union

from pipefunc._utils import at_least_tuple, dump, equal_dicts, load
from pipefunc._version import __version__
from pipefunc.map._mapspec import MapSpec, array_shape
from pipefunc.map._storage_base import StorageBase, storage_registry

if TYPE_CHECKING:
import sys

from pipefunc import Pipeline

if sys.version_info < (3, 10): # pragma: no cover
from typing_extensions import TypeAlias
else:
from typing import TypeAlias

_OUTPUT_TYPE: TypeAlias = Union[str, Tuple[str, ...]]
_OUTPUT_TYPE: TypeAlias = Union[str, tuple[str, ...]]


class Shapes(NamedTuple):
Expand Down
11 changes: 3 additions & 8 deletions pipefunc/map/adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import functools
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any, Generator, Tuple, Union
from typing import TYPE_CHECKING, Any, TypeAlias, Union

import numpy as np
from adaptive import SequenceLearner
Expand All @@ -28,21 +28,16 @@
from pipefunc.map._storage_base import _iterate_shape_indices

if TYPE_CHECKING:
import sys
from collections.abc import Generator

import numpy.typing as npt

from pipefunc import PipeFunc, Pipeline
from pipefunc.map._storage_base import StorageBase
from pipefunc.sweep import Sweep

if sys.version_info < (3, 10): # pragma: no cover
from typing_extensions import TypeAlias
else:
from typing import TypeAlias


_OUTPUT_TYPE: TypeAlias = Union[str, Tuple[str, ...]]
_OUTPUT_TYPE: TypeAlias = Union[str, tuple[str, ...]]


def create_learners(
Expand Down
6 changes: 4 additions & 2 deletions pipefunc/sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
from __future__ import annotations

from collections import defaultdict
from collections.abc import Iterable, Mapping
from collections.abc import Hashable, Iterable
from itertools import product
from typing import TYPE_CHECKING, Any, Callable, Generator, Hashable, Iterator, Sequence
from typing import TYPE_CHECKING, Any

import networkx as nx

from pipefunc._utils import at_least_tuple

if TYPE_CHECKING:
from collections.abc import Callable, Generator, Iterator, Mapping, Sequence

from pipefunc._pipeline import _OUTPUT_TYPE, PipeFunc, Pipeline


Expand Down
9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires = ["setuptools", "wheel", "versioningit"]
[project]
name = "pipefunc"
description = "A Python library for defining, managing, and executing function pipelines."
requires-python = ">=3.8"
requires-python = ">=3.10"
dynamic = ["version"]
maintainers = [{ name = "Bas Nijholt", email = "[email protected]" }]
license = { text = "MIT" }
Expand All @@ -17,8 +17,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -29,7 +27,6 @@ dependencies = [
"networkx",
"psutil",
"versioningit",
"typing_extensions; python_version <= '3.9'",
"cloudpickle",
"numpy",
]
Expand Down Expand Up @@ -107,7 +104,7 @@ omit = ["pipefunc/_plotting.py"]

[tool.ruff]
line-length = 100
target-version = "py38"
target-version = "py39"

[tool.ruff.lint]
select = ["ALL"]
Expand Down Expand Up @@ -140,4 +137,4 @@ ignore = [
max-complexity = 18

[tool.mypy]
python_version = "3.8"
python_version = "3.10"
9 changes: 7 additions & 2 deletions tests/map/test_base_filearray.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
from typing import Callable
from __future__ import annotations

from typing import TYPE_CHECKING

import numpy as np
import pytest
Expand All @@ -11,6 +12,10 @@
from pipefunc.map._storage_base import StorageBase, _iterate_shape_indices, _select_by_mask
from pipefunc.map.zarr import ZarrFileArray

if TYPE_CHECKING:
from collections.abc import Callable
from pathlib import Path


@pytest.fixture(params=["file_array", "zarr_array", "dict"])
def array_type(request, tmp_path: Path):
Expand Down
Loading

0 comments on commit 2e4c272

Please sign in to comment.