-
-
Notifications
You must be signed in to change notification settings - Fork 945
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce type hints (MVP) (#1947)
* chore: prepare for shipping type hints * chore: rerun `black` and enable a new mypy env * chore: use the correct Tox env name `mypy_tests` * chore(typing): re-add `types-jsonschema` to the main `mypy` gate * chore(typing): rename a shadowed parameter to make it obvious for `mypy` * chore(typing): add more types to test `mypy` behaviour wrt cythonized modules * feat(typing): add some more types (WiP) * feat(typing): add more annotations to `app.py` * feat(typing): add annotations to E2E server part * fix(typing): adapt to the new default (`no_implicit_optional=True`) * fix(typing): apply misc fixes to hopefully pass CI * docs(typing): add a provisional newsfragment * fix(typing): fix more `mypy` warnings/errors * chore(app_helpers): improve typing of middleware prep * refactor(typing): remove generics, type more stuff * chore: bluen the code
- Loading branch information
Showing
26 changed files
with
254 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
[run] | ||
branch = True | ||
source = falcon | ||
omit = falcon/tests*,falcon/cmd/bench.py,falcon/bench/*,falcon/vendor/* | ||
omit = falcon/tests*,falcon/typing.py,falcon/cmd/bench.py,falcon/bench/*,falcon/vendor/* | ||
|
||
parallel = True | ||
|
||
[report] | ||
show_missing = True | ||
exclude_lines = | ||
if TYPE_CHECKING: | ||
if not TYPE_CHECKING: | ||
pragma: nocover | ||
pragma: no cover | ||
pragma: no py39,py310 cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Basic typing annotations have been added to the most commonly used functions of | ||
Falcon's public interface to the package itself in order to better support | ||
`mypy <https://www.mypy-lang.org/>`_ users without having to install any | ||
third-party typeshed packages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
from http import HTTPStatus | ||
|
||
import falcon | ||
from falcon.asgi import Request, Response | ||
|
||
|
||
class Pong: | ||
async def on_get(self, req, resp): | ||
async def on_get(self, req: Request, resp: Response) -> None: | ||
resp.content_type = falcon.MEDIA_TEXT | ||
resp.text = 'PONG\n' | ||
resp.status = HTTPStatus.OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.