mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-11 13:06:43 +00:00
🎨 Add newly required type annotations for mypy (#2882)
* ⬆️ Upgrade mypy * 🎨 Add extra type annotations, now required by mypy
This commit is contained in:
parent
071c6a17dd
commit
4d208b2b90
3 changed files with 6 additions and 6 deletions
|
|
@ -752,7 +752,7 @@ def get_body_field(*, dependant: Dependant, name: str) -> Optional[ModelField]:
|
||||||
for param in flat_dependant.body_params:
|
for param in flat_dependant.body_params:
|
||||||
setattr(param.field_info, "embed", True)
|
setattr(param.field_info, "embed", True)
|
||||||
model_name = "Body_" + name
|
model_name = "Body_" + name
|
||||||
BodyModel = create_model(model_name)
|
BodyModel: Type[BaseModel] = create_model(model_name)
|
||||||
for f in flat_dependant.body_params:
|
for f in flat_dependant.body_params:
|
||||||
BodyModel.__fields__[f.name] = get_schema_compatible_field(field=f)
|
BodyModel.__fields__[f.name] = get_schema_compatible_field(field=f)
|
||||||
required = any(True for f in flat_dependant.body_params if f.required)
|
required = any(True for f in flat_dependant.body_params if f.required)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from typing import Any, Dict, Optional, Sequence
|
from typing import Any, Dict, Optional, Sequence, Type
|
||||||
|
|
||||||
from pydantic import ValidationError, create_model
|
from pydantic import BaseModel, ValidationError, create_model
|
||||||
from pydantic.error_wrappers import ErrorList
|
from pydantic.error_wrappers import ErrorList
|
||||||
from starlette.exceptions import HTTPException as StarletteHTTPException
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||||
|
|
||||||
|
|
@ -16,8 +16,8 @@ class HTTPException(StarletteHTTPException):
|
||||||
self.headers = headers
|
self.headers = headers
|
||||||
|
|
||||||
|
|
||||||
RequestErrorModel = create_model("Request")
|
RequestErrorModel: Type[BaseModel] = create_model("Request")
|
||||||
WebSocketErrorModel = create_model("WebSocket")
|
WebSocketErrorModel: Type[BaseModel] = create_model("WebSocket")
|
||||||
|
|
||||||
|
|
||||||
class FastAPIError(RuntimeError):
|
class FastAPIError(RuntimeError):
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ test = [
|
||||||
"pytest ==5.4.3",
|
"pytest ==5.4.3",
|
||||||
"pytest-cov ==2.10.0",
|
"pytest-cov ==2.10.0",
|
||||||
"pytest-asyncio >=0.14.0,<0.15.0",
|
"pytest-asyncio >=0.14.0,<0.15.0",
|
||||||
"mypy ==0.790",
|
"mypy ==0.812",
|
||||||
"flake8 >=3.8.3,<4.0.0",
|
"flake8 >=3.8.3,<4.0.0",
|
||||||
"black ==20.8b1",
|
"black ==20.8b1",
|
||||||
"isort >=5.0.6,<6.0.0",
|
"isort >=5.0.6,<6.0.0",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue