From 0de0e5e57f8f22e039b0d19aad6341ce7ab3da9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 4 Feb 2025 15:26:54 +0100 Subject: [PATCH 1/2] fix: Deactivate Pydantic validation on Python 3.9 is `eval-type-backport` is not available (for modern typing syntax support) Issue-241: https://github.com/mkdocstrings/python/issues/241 --- src/mkdocstrings_handlers/python/config.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mkdocstrings_handlers/python/config.py b/src/mkdocstrings_handlers/python/config.py index fa8aa009..3bab3920 100644 --- a/src/mkdocstrings_handlers/python/config.py +++ b/src/mkdocstrings_handlers/python/config.py @@ -7,12 +7,18 @@ from dataclasses import field, fields from typing import TYPE_CHECKING, Annotated, Any, Literal +from mkdocstrings.loggers import get_logger + # YORE: EOL 3.10: Replace block with line 2. if sys.version_info >= (3, 11): from typing import Self else: from typing_extensions import Self + +logger = get_logger(__name__) + + try: # When Pydantic is available, use it to validate options (done automatically). # Users can therefore opt into validation by installing Pydantic in development/CI. @@ -30,6 +36,17 @@ if getattr(pydantic, "__version__", "1.").startswith("1."): raise ImportError # noqa: TRY301 + if sys.version_info < (3, 10): + try: + import eval_type_backport # noqa: F401 + except ImportError: + logger.debug( + "Pydantic needs the `eval-type-backport` package to be installed " + "for modern type syntax to work on Python 3.9. " + "Deactivating Pydantic validation for Python handler options.", + ) + raise + from inspect import cleandoc from pydantic import Field as BaseField From 0ca64be892f9a470cb8502e3c3d7fd5329cac68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 4 Feb 2025 15:29:08 +0100 Subject: [PATCH 2/2] chore: Prepare release 1.14.4 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3a72ef9..9469c574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.14.4](https://github.com/mkdocstrings/python/releases/tag/1.14.4) - 2025-02-04 + +[Compare with 1.14.3](https://github.com/mkdocstrings/python/compare/1.14.3...1.14.4) + +### Bug Fixes + +- Deactivate Pydantic validation on Python 3.9 is `eval-type-backport` is not available (for modern typing syntax support) ([0de0e5e](https://github.com/mkdocstrings/python/commit/0de0e5e57f8f22e039b0d19aad6341ce7ab3da9f) by Timothée Mazzucotelli). [Issue-241](https://github.com/mkdocstrings/python/issues/241) + ## [1.14.3](https://github.com/mkdocstrings/python/releases/tag/1.14.3) - 2025-02-04 [Compare with 1.14.2](https://github.com/mkdocstrings/python/compare/1.14.2...1.14.3)