Browse Source

Merge cfdb9476d4 into 1d434dec47

pull/12970/merge
Tamir Duberstein 4 days ago
committed by GitHub
parent
commit
7c59740ad0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      fastapi/encoders.py
  2. 2
      fastapi/routing.py
  3. 6
      fastapi/security/api_key.py
  4. 1
      pyproject.toml
  5. 2
      requirements-tests.txt

2
fastapi/encoders.py

@ -240,7 +240,7 @@ def jsonable_encoder(
custom_encoder=encoders, custom_encoder=encoders,
sqlalchemy_safe=sqlalchemy_safe, sqlalchemy_safe=sqlalchemy_safe,
) )
if dataclasses.is_dataclass(obj): if dataclasses.is_dataclass(type(obj)):
obj_dict = dataclasses.asdict(obj) obj_dict = dataclasses.asdict(obj)
return jsonable_encoder( return jsonable_encoder(
obj_dict, obj_dict,

2
fastapi/routing.py

@ -118,7 +118,7 @@ def _prepare_response_content(
) )
for k, v in res.items() for k, v in res.items()
} }
elif dataclasses.is_dataclass(res): elif dataclasses.is_dataclass(type(res)):
return dataclasses.asdict(res) return dataclasses.asdict(res)
return res return res

6
fastapi/security/api_key.py

@ -100,7 +100,7 @@ class APIKeyQuery(APIKeyBase):
] = True, ] = True,
): ):
self.model: APIKey = APIKey( self.model: APIKey = APIKey(
**{"in": APIKeyIn.query}, # type: ignore[arg-type] **{"in": APIKeyIn.query},
name=name, name=name,
description=description, description=description,
) )
@ -188,7 +188,7 @@ class APIKeyHeader(APIKeyBase):
] = True, ] = True,
): ):
self.model: APIKey = APIKey( self.model: APIKey = APIKey(
**{"in": APIKeyIn.header}, # type: ignore[arg-type] **{"in": APIKeyIn.header},
name=name, name=name,
description=description, description=description,
) )
@ -276,7 +276,7 @@ class APIKeyCookie(APIKeyBase):
] = True, ] = True,
): ):
self.model: APIKey = APIKey( self.model: APIKey = APIKey(
**{"in": APIKeyIn.cookie}, # type: ignore[arg-type] **{"in": APIKeyIn.cookie},
name=name, name=name,
description=description, description=description,
) )

1
pyproject.toml

@ -123,6 +123,7 @@ source-includes = [
name = "fastapi-slim" name = "fastapi-slim"
[tool.mypy] [tool.mypy]
plugins = ["pydantic.mypy"]
strict = true strict = true
[[tool.mypy.overrides]] [[tool.mypy.overrides]]

2
requirements-tests.txt

@ -2,7 +2,7 @@
-r requirements-docs-tests.txt -r requirements-docs-tests.txt
pytest >=7.1.3,<9.0.0 pytest >=7.1.3,<9.0.0
coverage[toml] >= 6.5.0,< 8.0 coverage[toml] >= 6.5.0,< 8.0
mypy ==1.8.0 mypy ==1.13.0
dirty-equals ==0.8.0 dirty-equals ==0.8.0
sqlmodel==0.0.23 sqlmodel==0.0.23
flask >=1.1.2,<4.0.0 flask >=1.1.2,<4.0.0

Loading…
Cancel
Save