From ee03ec4fc6ec93d7e4ce9b0a6be8c0aa5edc4deb Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 11 Sep 2024 11:20:29 -0400 Subject: [PATCH] Drop support for 3.8, which is near EOL. --- .github/workflows/ci.yml | 1 - CHANGELOG.rst | 5 ++++ jsonschema/_format.py | 4 +--- jsonschema/_types.py | 6 ++++- jsonschema/_typing.py | 5 ++-- jsonschema/protocols.py | 11 ++------- .../tests/test_jsonschema_test_suite.py | 24 +++---------------- noxfile.py | 2 +- pyproject.toml | 5 ++-- 9 files changed, 22 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a01200b60..37ccb705c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,6 @@ jobs: uses: actions/setup-python@v5 with: python-version: | - 3.8 3.9 3.10 3.11 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a7b9d86eb..070573bb5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +v4.24.0 +======= + +* Support for Python 3.8 has been dropped, as it is nearing end-of-life. + v4.23.0 ======= diff --git a/jsonschema/_format.py b/jsonschema/_format.py index 6e87620cc..789fe4f27 100644 --- a/jsonschema/_format.py +++ b/jsonschema/_format.py @@ -13,9 +13,7 @@ _FormatCheckCallable = typing.Callable[[object], bool] #: A format checker callable. _F = typing.TypeVar("_F", bound=_FormatCheckCallable) -_RaisesType = typing.Union[ - typing.Type[Exception], typing.Tuple[typing.Type[Exception], ...], -] +_RaisesType = typing.Union[type[Exception], tuple[type[Exception], ...]] _RE_DATE = re.compile(r"^\d{4}-\d{2}-\d{2}$", re.ASCII) diff --git a/jsonschema/_types.py b/jsonschema/_types.py index bf25e7e6f..0cd175aad 100644 --- a/jsonschema/_types.py +++ b/jsonschema/_types.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Callable, Mapping +from typing import TYPE_CHECKING import numbers from attrs import evolve, field, frozen @@ -8,6 +8,10 @@ from jsonschema.exceptions import UndefinedTypeCheck +if TYPE_CHECKING: + from collections.abc import Mapping + from typing import Any, Callable + # unfortunately, the type of HashTrieMap is generic, and if used as an attrs # converter, the generic type is presented to mypy, which then fails to match diff --git a/jsonschema/_typing.py b/jsonschema/_typing.py index d283dc48d..1d091d70c 100644 --- a/jsonschema/_typing.py +++ b/jsonschema/_typing.py @@ -1,7 +1,8 @@ """ Some (initially private) typing helpers for jsonschema's types. """ -from typing import Any, Callable, Iterable, Protocol, Tuple, Union +from collections.abc import Iterable +from typing import Any, Callable, Protocol, Union import referencing.jsonschema @@ -24,5 +25,5 @@ def __call__( ApplicableValidators = Callable[ [referencing.jsonschema.Schema], - Iterable[Tuple[str, Any]], + Iterable[tuple[str, Any]], ] diff --git a/jsonschema/protocols.py b/jsonschema/protocols.py index 39e56d0fa..93cd99f4f 100644 --- a/jsonschema/protocols.py +++ b/jsonschema/protocols.py @@ -7,21 +7,14 @@ from __future__ import annotations -from typing import ( - TYPE_CHECKING, - Any, - ClassVar, - Iterable, - Protocol, - runtime_checkable, -) +from typing import TYPE_CHECKING, ClassVar, Protocol, runtime_checkable # in order for Sphinx to resolve references accurately from type annotations, # it needs to see names like `jsonschema.TypeChecker` # therefore, only import at type-checking time (to avoid circular references), # but use `jsonschema` for any types which will otherwise not be resolvable if TYPE_CHECKING: - from collections.abc import Mapping + from collections.abc import Any, Iterable, Mapping import referencing.jsonschema diff --git a/jsonschema/tests/test_jsonschema_test_suite.py b/jsonschema/tests/test_jsonschema_test_suite.py index 282c1369c..d1b0ebc05 100644 --- a/jsonschema/tests/test_jsonschema_test_suite.py +++ b/jsonschema/tests/test_jsonschema_test_suite.py @@ -6,7 +6,6 @@ See https://github.com/json-schema-org/JSON-Schema-Test-Suite for details. """ -import sys from jsonschema.tests._suite import Suite import jsonschema @@ -66,18 +65,6 @@ def complex_email_validation(test): )(test) -if sys.version_info < (3, 9): # pragma: no cover - message = "Rejecting leading zeros is 3.9+" - allowed_leading_zeros = skip( - message=message, - subject="ipv4", - description="invalid leading zeroes, as they are treated as octals", - ) -else: - def allowed_leading_zeros(test): # pragma: no cover - return - - def leap_second(test): message = "Leap seconds are unsupported." return skip( @@ -149,8 +136,7 @@ def leap_second(test): Validator=jsonschema.Draft4Validator, format_checker=jsonschema.Draft4Validator.FORMAT_CHECKER, skip=lambda test: ( - allowed_leading_zeros(test) - or leap_second(test) + leap_second(test) or missing_format(jsonschema.Draft4Validator)(test) or complex_email_validation(test) ), @@ -167,8 +153,7 @@ def leap_second(test): Validator=jsonschema.Draft6Validator, format_checker=jsonschema.Draft6Validator.FORMAT_CHECKER, skip=lambda test: ( - allowed_leading_zeros(test) - or leap_second(test) + leap_second(test) or missing_format(jsonschema.Draft6Validator)(test) or complex_email_validation(test) ), @@ -187,8 +172,7 @@ def leap_second(test): Validator=jsonschema.Draft7Validator, format_checker=jsonschema.Draft7Validator.FORMAT_CHECKER, skip=lambda test: ( - allowed_leading_zeros(test) - or leap_second(test) + leap_second(test) or missing_format(jsonschema.Draft7Validator)(test) or complex_email_validation(test) ), @@ -224,7 +208,6 @@ def leap_second(test): format_checker=jsonschema.Draft201909Validator.FORMAT_CHECKER, skip=lambda test: ( complex_email_validation(test) - or allowed_leading_zeros(test) or leap_second(test) or missing_format(jsonschema.Draft201909Validator)(test) or complex_email_validation(test) @@ -261,7 +244,6 @@ def leap_second(test): format_checker=jsonschema.Draft202012Validator.FORMAT_CHECKER, skip=lambda test: ( complex_email_validation(test) - or allowed_leading_zeros(test) or leap_second(test) or missing_format(jsonschema.Draft202012Validator)(test) or complex_email_validation(test) diff --git a/noxfile.py b/noxfile.py index fada3e1f8..c574abca9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -35,7 +35,7 @@ "The Unlicense (Unlicense)", ] -SUPPORTED = ["3.8", "3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"] +SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"] LATEST_STABLE = "3.12" nox.options.sessions = [] diff --git a/pyproject.toml b/pyproject.toml index 6cd7c18fa..a76862eaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ source = "vcs" [project] name = "jsonschema" description = "An implementation of JSON Schema validation for Python" -requires-python = ">=3.8" +requires-python = ">=3.9" license = {text = "MIT"} keywords = [ "validation", @@ -26,7 +26,6 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -198,7 +197,7 @@ ignore = [ "SLF001", # Private usage within this package itself is fine "TD", # These TODO style rules are also silly "TRY003", # Some exception classes are essentially intended for free-form - "UP007", # We support 3.8 + 3.9 + "UP007", # We support 3.9 ] [tool.ruff.lint.flake8-pytest-style]