3333 Undefined ,
3434 copy_field_info ,
3535 create_body_model ,
36- evaluate_forwardref ,
36+ evaluate_forwardref , # ty: ignore[deprecated]
3737 field_annotation_is_scalar ,
3838 field_annotation_is_scalar_sequence ,
3939 field_annotation_is_sequence ,
@@ -100,12 +100,14 @@ def ensure_multipart_is_installed() -> None:
100100 except (ImportError , AssertionError ):
101101 try :
102102 # __version__ is available in both multiparts, and can be mocked
103- from multipart import __version__ # type: ignore[no-redef,import-untyped]
103+ from multipart import ( # type: ignore[no-redef,import-untyped] # ty: ignore[unused-ignore-comment]
104+ __version__ ,
105+ )
104106
105107 assert __version__
106108 try :
107109 # parse_options_header is only available in the right multipart
108- from multipart .multipart import ( # type: ignore[import-untyped]
110+ from multipart .multipart import ( # type: ignore[import-untyped] # ty: ignore[unused-ignore-comment]
109111 parse_options_header ,
110112 )
111113
@@ -243,7 +245,7 @@ def get_typed_signature(call: Callable[..., Any]) -> inspect.Signature:
243245def get_typed_annotation (annotation : Any , globalns : dict [str , Any ]) -> Any :
244246 if isinstance (annotation , str ):
245247 annotation = ForwardRef (annotation )
246- annotation = evaluate_forwardref (annotation , globalns , globalns )
248+ annotation = evaluate_forwardref (annotation , globalns , globalns ) # ty: ignore[deprecated]
247249 if annotation is type (None ):
248250 return None
249251 return annotation
@@ -320,8 +322,9 @@ def get_dependant(
320322 and param_details .depends .scope == "function"
321323 ):
322324 assert dependant .call
325+ call_name = getattr (dependant .call , "__name__" , "<unnamed_callable>" )
323326 raise DependencyScopeError (
324- f'The dependency "{ dependant . call . __name__ } " has a scope of '
327+ f'The dependency "{ call_name } " has a scope of '
325328 '"request", it cannot depend on dependencies with scope "function".'
326329 )
327330 sub_own_oauth_scopes : list [str ] = []
@@ -596,7 +599,7 @@ async def solve_dependencies(
596599 * ,
597600 request : Request | WebSocket ,
598601 dependant : Dependant ,
599- body : dict [str , Any ] | FormData | None = None ,
602+ body : dict [str , Any ] | FormData | bytes | None = None ,
600603 background_tasks : StarletteBackgroundTasks | None = None ,
601604 response : Response | None = None ,
602605 dependency_overrides_provider : Any | None = None ,
@@ -619,7 +622,7 @@ async def solve_dependencies(
619622 if response is None :
620623 response = Response ()
621624 del response .headers ["content-length" ]
622- response .status_code = None # type: ignore
625+ response .status_code = None # type: ignore # ty: ignore[unused-ignore-comment]
623626 if dependency_cache is None :
624627 dependency_cache = {}
625628 for sub_dependant in dependant .dependencies :
@@ -826,7 +829,7 @@ def request_params_to_args(
826829
827830 for key in received_params .keys ():
828831 if key not in processed_keys :
829- if hasattr (received_params , "getlist" ):
832+ if isinstance (received_params , ( ImmutableMultiDict , Headers ) ):
830833 value = received_params .getlist (key )
831834 if isinstance (value , list ) and (len (value ) == 1 ):
832835 params_to_process [key ] = value [0 ]
@@ -947,7 +950,7 @@ async def _extract_form_body(
947950
948951async def request_body_to_args (
949952 body_fields : list [ModelField ],
950- received_body : dict [str , Any ] | FormData | None ,
953+ received_body : dict [str , Any ] | FormData | bytes | None ,
951954 embed_body_fields : bool ,
952955) -> tuple [dict [str , Any ], list [dict [str , Any ]]]:
953956 values : dict [str , Any ] = {}
@@ -978,7 +981,7 @@ async def request_body_to_args(
978981 for field in body_fields :
979982 loc = ("body" , get_validation_alias (field ))
980983 value : Any | None = None
981- if body_to_process is not None :
984+ if body_to_process is not None and not isinstance ( body_to_process , bytes ) :
982985 try :
983986 value = body_to_process .get (get_validation_alias (field ))
984987 # If the received body is a list, not a dict
0 commit comments