Skip to content

Commit

Permalink
Run mypy with falcon 4.x (#1199)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Nov 5, 2024
1 parent f6fc477 commit 0396b3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements/adapter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ chalice>=1.28,<2; python_version>"3.6"
CherryPy>=18,<19
Django>=3,<6
falcon>=2,<4; python_version<"3.11"
falcon>=3.1.1,<4; python_version>="3.11"
falcon>=3.1.1,<5; python_version>="3.11"
fastapi>=0.70.0,<1
Flask>=1,<4
Werkzeug>=2,<4
Expand Down
7 changes: 4 additions & 3 deletions slack_bolt/adapter/falcon/async_resource.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from datetime import datetime
from http import HTTPStatus

from falcon import version as falcon_version # type: ignore[import-untyped]
from falcon.asgi import Request, Response # type: ignore[import-untyped]
from falcon import version as falcon_version
from falcon.asgi import Request, Response
from slack_bolt import BoltResponse
from slack_bolt.async_app import AsyncApp
from slack_bolt.error import BoltError
Expand Down Expand Up @@ -41,7 +41,8 @@ async def on_get(self, req: Request, resp: Response):
return

resp.status = "404"
resp.body = "The page is not found..."
# Falcon 4.x w/ mypy fails to correctly infer the str type here
resp.body = "The page is not found..." # type: ignore[assignment]

async def on_post(self, req: Request, resp: Response):
bolt_req = await self._to_bolt_request(req)
Expand Down
8 changes: 5 additions & 3 deletions slack_bolt/adapter/falcon/resource.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
from http import HTTPStatus

from falcon import Request, Response, version as falcon_version # type: ignore[import-untyped]
from falcon import Request, Response, version as falcon_version

from slack_bolt import BoltResponse
from slack_bolt.app import App
Expand Down Expand Up @@ -35,7 +35,8 @@ def on_get(self, req: Request, resp: Response):
return

resp.status = "404"
resp.body = "The page is not found..."
# Falcon 4.x w/ mypy fails to correctly infer the str type here
resp.body = "The page is not found..." # type: ignore[assignment]

def on_post(self, req: Request, resp: Response):
bolt_req = self._to_bolt_request(req)
Expand All @@ -51,7 +52,8 @@ def _to_bolt_request(self, req: Request) -> BoltRequest:

def _write_response(self, bolt_resp: BoltResponse, resp: Response):
if falcon_version.__version__.startswith("2."):
resp.body = bolt_resp.body
# Falcon 4.x w/ mypy fails to correctly infer the str type here
resp.body = bolt_resp.body # type: ignore[assignment]
else:
resp.text = bolt_resp.body

Expand Down

0 comments on commit 0396b3b

Please sign in to comment.