diff --git a/pkgs/development/python-modules/pydantic-core/default.nix b/pkgs/development/python-modules/pydantic-core/default.nix index cc9854b46853d..834eabe92cf8d 100644 --- a/pkgs/development/python-modules/pydantic-core/default.nix +++ b/pkgs/development/python-modules/pydantic-core/default.nix @@ -28,7 +28,13 @@ let hash = "sha256-RXytujvx/23Z24TWpvnHdjJ4/dXqjs5uiavUmukaD9A="; }; - patches = [ ./01-remove-benchmark-flags.patch ]; + patches = [ + ./01-remove-benchmark-flags.patch + + # Fix missing recursive_guard paramter value on 3.12.4 and newer, based on + # https://github.com/pydantic/pydantic-core/commit/d7946da7455fc269f69d6ae01abe2ba61266a0f2 + ./python3.12.4-compat.patch + ]; cargoDeps = rustPlatform.fetchCargoTarball { inherit src; diff --git a/pkgs/development/python-modules/pydantic-core/python3.12.4-compat.patch b/pkgs/development/python-modules/pydantic-core/python3.12.4-compat.patch new file mode 100644 index 0000000000000..e586ac620f2e7 --- /dev/null +++ b/pkgs/development/python-modules/pydantic-core/python3.12.4-compat.patch @@ -0,0 +1,30 @@ +diff --git a/generate_self_schema.py b/generate_self_schema.py +index 8d27247..814c88e 100644 +--- a/generate_self_schema.py ++++ b/generate_self_schema.py +@@ -9,6 +9,7 @@ from __future__ import annotations as _annotations + import decimal + import importlib.util + import re ++import sys + from collections.abc import Callable + from datetime import date, datetime, time, timedelta + from pathlib import Path +@@ -188,12 +189,12 @@ def all_literal_values(type_: type[core_schema.Literal]) -> list[any]: + + + def eval_forward_ref(type_: Any) -> Any: +- try: +- return type_._evaluate(core_schema.__dict__, None, set()) +- except TypeError: +- # for Python 3.8 ++ if sys.version_info < (3, 9): + return type_._evaluate(core_schema.__dict__, None) +- ++ elif sys.version_info < (3, 12, 4): ++ return type_._evaluate(core_schema.__dict__, None, recursive_guard=set()) ++ else: ++ return type_._evaluate(core_schema.__dict__, None, type_params=set(), recursive_guard=set()) + + def main() -> None: + schema_union = core_schema.CoreSchema