Skip to content

Commit

Permalink
fix MyPy errors with the latest version of FastAPI (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinisaos committed Sep 27, 2022
1 parent e825b90 commit 99077f5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion piccolo_api/change_password/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def post(self, request: Request) -> Response:

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

if not body:
try:
Expand Down
10 changes: 7 additions & 3 deletions piccolo_api/crud/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,13 @@ async def get_ids(self, request: Request) -> Response:
"""
readable = self.table.get_readable()
query = self.table.select().columns(
query: t.Any = self.table.select().columns(
self.table._meta.primary_key._meta.name, readable
)

limit = request.query_params.get("limit")
limit: t.Union[t.Optional[str], int] = request.query_params.get(
"limit", None
)
if limit is not None:
try:
limit = int(limit)
Expand All @@ -367,7 +369,9 @@ async def get_ids(self, request: Request) -> Response:
else:
limit = "ALL"

offset = request.query_params.get("offset")
offset: t.Union[t.Optional[str], int] = request.query_params.get(
"offset", None
)
if offset is not None:
try:
offset = int(offset)
Expand Down
2 changes: 1 addition & 1 deletion piccolo_api/register/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async def post(self, request: Request) -> Response:

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

if not body:
try:
Expand Down
2 changes: 1 addition & 1 deletion piccolo_api/session_auth/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async def get(self, request: Request) -> HTMLResponse:
async def post(self, request: Request) -> Response:
# Some middleware (for example CSRF) has already awaited the request
# body, and adds it to the request.
body = request.scope.get("form")
body: t.Any = request.scope.get("form")

if not body:
try:
Expand Down
3 changes: 0 additions & 3 deletions requirements/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ twine==3.2.0
mypy==0.950
pip-upgrader==1.4.15
wheel==0.37.1

# Version pin FastAPI, so MyPy is more predictable.
fastapi==0.65.2

0 comments on commit 99077f5

Please sign in to comment.