Skip to content

Commit 99077f5

Browse files
authored
fix MyPy errors with the latest version of FastAPI (#193)
1 parent e825b90 commit 99077f5

5 files changed

Lines changed: 10 additions & 9 deletions

File tree

piccolo_api/change_password/endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async def post(self, request: Request) -> Response:
100100

101101
# Some middleware (for example CSRF) has already awaited the request
102102
# body, and adds it to the request.
103-
body = request.scope.get("form")
103+
body: t.Any = request.scope.get("form")
104104

105105
if not body:
106106
try:

piccolo_api/crud/endpoints.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,13 @@ async def get_ids(self, request: Request) -> Response:
352352
353353
"""
354354
readable = self.table.get_readable()
355-
query = self.table.select().columns(
355+
query: t.Any = self.table.select().columns(
356356
self.table._meta.primary_key._meta.name, readable
357357
)
358358

359-
limit = request.query_params.get("limit")
359+
limit: t.Union[t.Optional[str], int] = request.query_params.get(
360+
"limit", None
361+
)
360362
if limit is not None:
361363
try:
362364
limit = int(limit)
@@ -367,7 +369,9 @@ async def get_ids(self, request: Request) -> Response:
367369
else:
368370
limit = "ALL"
369371

370-
offset = request.query_params.get("offset")
372+
offset: t.Union[t.Optional[str], int] = request.query_params.get(
373+
"offset", None
374+
)
371375
if offset is not None:
372376
try:
373377
offset = int(offset)

piccolo_api/register/endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def post(self, request: Request) -> Response:
9999

100100
# Some middleware (for example CSRF) has already awaited the request
101101
# body, and adds it to the request.
102-
body = request.scope.get("form")
102+
body: t.Any = request.scope.get("form")
103103

104104
if not body:
105105
try:

piccolo_api/session_auth/endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ async def get(self, request: Request) -> HTMLResponse:
195195
async def post(self, request: Request) -> Response:
196196
# Some middleware (for example CSRF) has already awaited the request
197197
# body, and adds it to the request.
198-
body = request.scope.get("form")
198+
body: t.Any = request.scope.get("form")
199199

200200
if not body:
201201
try:

requirements/dev-requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@ twine==3.2.0
44
mypy==0.950
55
pip-upgrader==1.4.15
66
wheel==0.37.1
7-
8-
# Version pin FastAPI, so MyPy is more predictable.
9-
fastapi==0.65.2

0 commit comments

Comments
 (0)