Browse Source

♻️ Remove Python 3.9 specific logic

pull/14897/head
Sebastián Ramírez 5 months ago
parent
commit
1d76345f98
  1. 7
      fastapi/_compat/shared.py
  2. 3
      fastapi/dependencies/utils.py

7
fastapi/_compat/shared.py

@ -21,14 +21,11 @@ from typing_extensions import TypeGuard, get_args, get_origin
_T = TypeVar("_T") _T = TypeVar("_T")
# Copy from Pydantic: pydantic/_internal/_typing_extra.py # Copy from Pydantic: pydantic/_internal/_typing_extra.py
if sys.version_info < (3, 10): WithArgsTypes: tuple[Any, ...] = (
WithArgsTypes: tuple[Any, ...] = (typing._GenericAlias, types.GenericAlias) # type: ignore[attr-defined]
else:
WithArgsTypes: tuple[Any, ...] = (
typing._GenericAlias, # type: ignore[attr-defined] typing._GenericAlias, # type: ignore[attr-defined]
types.GenericAlias, types.GenericAlias,
types.UnionType, types.UnionType,
) # pyright: ignore[reportAttributeAccessIssue] ) # pyright: ignore[reportAttributeAccessIssue]
PYDANTIC_VERSION_MINOR_TUPLE = tuple(int(x) for x in PYDANTIC_VERSION.split(".")[:2]) PYDANTIC_VERSION_MINOR_TUPLE = tuple(int(x) for x in PYDANTIC_VERSION.split(".")[:2])

3
fastapi/dependencies/utils.py

@ -199,7 +199,6 @@ def get_flat_params(dependant: Dependant) -> list[ModelField]:
def _get_signature(call: Callable[..., Any]) -> inspect.Signature: def _get_signature(call: Callable[..., Any]) -> inspect.Signature:
if sys.version_info >= (3, 10):
try: try:
signature = inspect.signature(call, eval_str=True) signature = inspect.signature(call, eval_str=True)
except NameError: except NameError:
@ -211,8 +210,6 @@ def _get_signature(call: Callable[..., Any]) -> inspect.Signature:
signature = inspect.signature(call, annotation_format=Format.FORWARDREF) signature = inspect.signature(call, annotation_format=Format.FORWARDREF)
else: else:
signature = inspect.signature(call) signature = inspect.signature(call)
else:
signature = inspect.signature(call)
return signature return signature

Loading…
Cancel
Save