python312Packages.pydantic: patch to work with python 3.12.4

It's mostly copy&paste from 10a52dcfd3
Example log:
  https://hydra.nixos.org/build/263580234/nixlog/2/tail
This commit is contained in:
Vladimír Čunát 2024-06-22 09:25:37 +02:00
parent a601f3f34f
commit ff8149e411
No known key found for this signature in database
GPG Key ID: E747DF1F9575A3AA
2 changed files with 23 additions and 0 deletions

View File

@ -48,6 +48,7 @@ buildPythonPackage rec {
url = "https://github.com/pydantic/pydantic/commit/825a6920e177a3b65836c13c7f37d82b810ce482.patch";
hash = "sha256-Dap5DtDzHw0jS/QUo5CRI9sLDJ719GRyC4ZNDWEdzus=";
})
./python3.12.4-compat.patch
];
buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];

View File

@ -0,0 +1,22 @@
--- a/pydantic/v1/typing.py
+++ b/pydantic/v1/typing.py
@@ -58,13 +58,18 @@
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
return type_._evaluate(globalns, localns)
-else:
+elif sys.version_info < (3, 12, 4):
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
# Even though it is the right signature for python 3.9, mypy complains with
# `error: Too many arguments for "_evaluate" of "ForwardRef"` hence the cast...
return cast(Any, type_)._evaluate(globalns, localns, set())
+else:
+
+ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
+ return cast(Any, type_)._evaluate(globalns, localns, type_params=set(), recursive_guard=set())
+
if sys.version_info < (3, 9):
# Ensure we always get all the whole `Annotated` hint, not just the annotated type.