From 00fb3859ab3236020d399af16c6f77c97a1fd3c3 Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:20:00 +0300 Subject: [PATCH 1/4] feat: drop support for and testing on Python 3.8 --- .github/workflows/python-package.yml | 3 +-- pyproject.toml | 2 +- setup.cfg | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 96e4cd6e5..fa13f8767 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -88,7 +88,6 @@ jobs: - windows-latest - macos-latest python-version: - - '3.8' - '3.9' - '3.10' - '3.11' @@ -105,7 +104,7 @@ jobs: python-version: '3.13-dev' include: - os: ubuntu-latest - python-version: '3.8' + python-version: '3.9' constraints: '--constraint constraints-oldest.txt' - os: ubuntu-latest python-version: '3.12' diff --git a/pyproject.toml b/pyproject.toml index 695aeca7a..37f79fa79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ requires = ["setuptools", "wheel"] # PEP 508 specifications. # Darker makes Black read its configuration from the file indicated by the `--config` # option, so we need to mirror the same configuration here and in `check-darker.toml`. skip-string-normalization = false -target-version = ["py38", "py39", "py310", "py311", "py312"] +target-version = ["py39", "py310", "py311", "py312"] [tool.isort] # Darker makes isort read its configuration from the file indicated by the `--config` diff --git a/setup.cfg b/setup.cfg index f30182804..ac5579aca 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,6 @@ description = Apply Black formatting only in regions changed since last commit long_description_content_type = text/x-rst classifiers = Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 @@ -33,7 +32,7 @@ install_requires = typing_extensions>=4.0.1 # NOTE: remember to keep `.github/workflows/python-package.yml` in sync # with the minimum required Python version -python_requires = >=3.8 +python_requires = >=3.9 [options.packages.find] where = src From 948e0a88ff774c94c11e36c11973ce686dac13be Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:21:10 +0300 Subject: [PATCH 2/4] test: lint/format files with py39+ rules --- .github/workflows/pyupgrade.yml | 2 +- pyproject.toml | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pyupgrade.yml b/.github/workflows/pyupgrade.yml index 22af5bbdf..a15c0bb7e 100644 --- a/.github/workflows/pyupgrade.yml +++ b/.github/workflows/pyupgrade.yml @@ -20,5 +20,5 @@ jobs: from pyupgrade._main import main from glob import glob files = glob('**/*.py', recursive=True) - sys.exit(main(files + ['--py38-plus'])) + sys.exit(main(files + ['--py39-plus'])) " || ( git diff ; false ) diff --git a/pyproject.toml b/pyproject.toml index 37f79fa79..c0146ee94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ src = ["."] disable = ["wrong-import-order"] [tool.ruff] -target-version = "py38" +target-version = "py39" [tool.ruff.lint] select = ["ALL"] @@ -47,10 +47,6 @@ ignore = [ "D203", # One blank line required before class docstring "D213", # Multi-line docstring summary should start at the second line "D400", # First line should end with a period (duplicates D415) - - # Remove these when support for Python 3.8 is dropped: - "UP006", # Use `xyz` instead of `Xyz` for type annotation - "UP007", # Use `X | Y` for type annotations ] [tool.ruff.lint.per-file-ignores] From 461b7e57795b4e535dcd0cbb8802a4c248254269 Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:21:29 +0300 Subject: [PATCH 3/4] feat: remove py38 work-arounds --- src/darker/concurrency.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/darker/concurrency.py b/src/darker/concurrency.py index a496bac59..bd0d7ab9e 100644 --- a/src/darker/concurrency.py +++ b/src/darker/concurrency.py @@ -1,25 +1,10 @@ """Concurrency helpers for enhancing the performance of Darker""" -import sys from concurrent.futures import Executor, Future, ProcessPoolExecutor -from typing import Any, Callable, Generic, TypeVar, cast +from typing import Any, Callable, TypeVar T = TypeVar("T") # pylint: disable=invalid-name -if sys.version_info < (3, 9): - - class FutureType(Generic[T]): - """For Python <3.9 compatibility""" - - def set_exception(self, exc_info: BaseException) -> None: - "Dummy method for typing" - - def set_result(self, result: Any) -> None: - "Dummy method for typing" - -else: - FutureType = Future - class DummyExecutor(Executor): """Dummy synchronous executor to use with ``--workers=1`` @@ -31,7 +16,7 @@ class DummyExecutor(Executor): # pylint: disable=arguments-differ,unsubscriptable-object,broad-except def submit( # type: ignore[override] self, fn: Callable[..., T], *args: Any, **kwargs: Any - ) -> FutureType[T]: + ) -> Future[T]: """Submits "a callable to be executed with the given arguments. Executes the callable immediately as ``fn(*args, **kwargs)`` and returns a @@ -43,7 +28,7 @@ def submit( # type: ignore[override] :return: A `Future` representing the given call """ - future = cast(FutureType[T], Future()) + future: Future[T] = Future() try: result = fn(*args, **kwargs) except BaseException as exc_info: # noqa: B036 From c3e65986664c72b5b0822d771460ade1ac88658d Mon Sep 17 00:00:00 2001 From: Antti Kaihola <13725+akaihola@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:21:47 +0300 Subject: [PATCH 4/4] docs: don't use py38 in examples --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 7a79d3d6c..980f0654c 100644 --- a/README.rst +++ b/README.rst @@ -415,7 +415,7 @@ An example ``pyproject.toml`` configuration file: line-length = 88 # Overridden by [tool.darker] above skip-magic-trailing-comma = false skip-string-normalization = false - target-version = ["py38", "py39", "py310", "py311", "py312"] # Overridden above + target-version = ["py39", "py310", "py311", "py312"] # Overridden above exclude = "test_*\.py" extend_exclude = "/generated/" force_exclude = ".*\.pyi"