Browse Source

♻️ Refactor None return type check to account for NoneType and avoid string literal

pull/9425/head
Sebastián Ramírez 10 months ago
parent
commit
b3e066afe2
  1. 4
      fastapi/dependencies/utils.py

4
fastapi/dependencies/utils.py

@ -248,6 +248,8 @@ def get_typed_annotation(annotation: Any, globalns: Dict[str, Any]) -> Any:
if isinstance(annotation, str):
annotation = ForwardRef(annotation)
annotation = evaluate_forwardref(annotation, globalns, globalns)
if annotation is type(None):
return None
return annotation
@ -255,7 +257,7 @@ def get_typed_return_annotation(call: Callable[..., Any]) -> Any:
signature = inspect.signature(call)
annotation = signature.return_annotation
if annotation == "None" or annotation is inspect.Signature.empty:
if annotation is inspect.Signature.empty:
return None
globalns = getattr(call, "__globals__", {})

Loading…
Cancel
Save