Browse Source

make mypy happy

pull/15101/head
svlandeg 4 months ago
parent
commit
97ce5de0bf
  1. 17
      fastapi/_compat/v2.py

17
fastapi/_compat/v2.py

@ -1,6 +1,6 @@
import re
import warnings
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from copy import copy
from dataclasses import dataclass, is_dataclass
from enum import Enum
@ -39,11 +39,16 @@ from pydantic_core.core_schema import (
RequiredParam = PydanticUndefined
Undefined = PydanticUndefined
# eval_type_lenient has been deprecated since Pydantic v2.10.0b1 (PR #10530)
evaluate_forwardref = getattr(_pydantic_typing_extra, "try_eval_type", None)
if evaluate_forwardref is None:
evaluate_forwardref = _pydantic_typing_extra.eval_type_lenient
assert evaluate_forwardref is not None
def define_forwardref() -> Callable[..., Any]:
# eval_type_lenient has been deprecated since Pydantic v2.10.0b1 (PR #10530)
eval_type = getattr(_pydantic_typing_extra, "try_eval_type", None)
if eval_type is not None:
return cast(Callable[..., Any], eval_type)
return _pydantic_typing_extra.eval_type_lenient
evaluate_forwardref = define_forwardref()
class GenerateJsonSchema(_GenerateJsonSchema):

Loading…
Cancel
Save