Browse Source

fix: use None sentinel instead of mutable OAuthFlowsModel() default in OAuth2.__init__

pull/15993/head
Rahul Rao 7 days ago
parent
commit
a57a8e54fa
  1. 4
      fastapi/security/oauth2.py

4
fastapi/security/oauth2.py

@ -350,7 +350,7 @@ class OAuth2(SecurityBase):
The dictionary of OAuth2 flows. The dictionary of OAuth2 flows.
""" """
), ),
] = OAuthFlowsModel(), ] = None,
scheme_name: Annotated[ scheme_name: Annotated[
str | None, str | None,
Doc( Doc(
@ -392,6 +392,8 @@ class OAuth2(SecurityBase):
), ),
] = True, ] = True,
): ):
if flows is None:
flows = OAuthFlowsModel()
self.model = OAuth2Model( self.model = OAuth2Model(
flows=cast(OAuthFlowsModel, flows), description=description flows=cast(OAuthFlowsModel, flows), description=description
) )

Loading…
Cancel
Save