-
-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue2382
- Loading branch information
Showing
16 changed files
with
571 additions
and
101 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -20,3 +20,4 @@ Framework Reference | |
inspect | ||
util | ||
testing | ||
typing |
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,83 @@ | ||
Typing | ||
====== | ||
|
||
Type checking support was introduced in version 4.0. While most of the library is | ||
now typed, further type annotations may be added throughout the 4.x release cycle. | ||
To improve them, we may introduce changes to the typing that do not affect | ||
runtime behavior, but may surface new or different errors with type checkers. | ||
|
||
.. role:: python(code) | ||
:language: python | ||
|
||
.. note:: | ||
All undocumented type aliases coming from ``falcon._typing`` are considered | ||
private to the framework itself, and not meant for annotating applications | ||
using Falcon. To that end, it is advisable to only use classes from the | ||
public interface, and public aliases from :mod:`falcon.typing`, e.g.: | ||
|
||
.. code-block:: python | ||
class MyResource: | ||
def on_get(self, req: falcon.Request, resp: falcon.Response) -> None: | ||
resp.media = {'message': 'Hello, World!'} | ||
If you still decide to reuse the private aliases anyway, they should | ||
preferably be imported inside :python:`if TYPE_CHECKING:` blocks in order | ||
to avoid possible runtime errors after an update. | ||
Also, make sure to :ref:`let us know <chat>` which essential aliases are | ||
missing from the public interface! | ||
|
||
|
||
Known Limitations | ||
----------------- | ||
|
||
Falcon's emphasis on flexibility and performance presents certain | ||
challenges when it comes to adding type annotations to the existing code base. | ||
|
||
One notable limitation involves using custom :class:`~falcon.Request` and/or | ||
:class:`~falcon.Response` types in callbacks that are passed back | ||
to the framework, such as when adding an | ||
:meth:`error handler <falcon.App.add_error_handler>`. | ||
For instance, the following application might unexpectedly not pass type | ||
checking: | ||
|
||
.. code-block:: python | ||
from typing import Any | ||
from falcon import App, HTTPInternalServerError, Request, Response | ||
class MyRequest(Request): | ||
... | ||
def handle_os_error(req: MyRequest, resp: Response, ex: Exception, | ||
params: dict[str, Any]) -> None: | ||
raise HTTPInternalServerError(title='OS error!') from ex | ||
app = App(request_type=MyRequest) | ||
app.add_error_handler(OSError, handle_os_error) | ||
(We are working on addressing this limitation at the time of writing -- | ||
please see the following GitHub issue for the progress, and possible solutions: | ||
`#2372 <https://github.com/falconry/falcon/issues/2372>`__.) | ||
|
||
Another known inconsistency is the typing of the | ||
:class:`converter interface <falcon.routing.BaseConverter>`, where certain | ||
subclasses (such as :class:`~falcon.routing.PathConverter`) declare a different | ||
input type than the base ``convert()`` method. | ||
(See also the discussions and possible solutions on the GitHub issue | ||
`#2396 <https://github.com/falconry/falcon/issues/2396>`__.) | ||
|
||
.. important:: | ||
The above issues are only typing limitations that have no effect outside of | ||
type checking -- applications will work just fine at runtime! | ||
|
||
|
||
Public Type Aliases | ||
------------------- | ||
|
||
.. automodule:: falcon.typing | ||
:members: |
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 |
---|---|---|
|
@@ -89,9 +89,3 @@ Other | |
|
||
.. autoclass:: falcon.ETag | ||
:members: | ||
|
||
Type Aliases | ||
------------ | ||
|
||
.. automodule:: falcon.typing | ||
:members: |
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,38 @@ | ||
Changelog for Falcon 4.0.2 | ||
========================== | ||
|
||
Summary | ||
------- | ||
|
||
This is a minor point release to fix some missed re-exports for type checkers. | ||
In addition, we have also included a couple of documentation improvements. | ||
|
||
|
||
Fixed | ||
----- | ||
|
||
- Running Mypy on code that uses parts of ``falcon.testing`` | ||
would previously lead to errors like:: | ||
|
||
Name "falcon.testing.TestClient" is not defined | ||
|
||
This has been fixed by explicitly exporting the names that are | ||
imported into the ``falcon.testing`` namespace. (`#2387 <https://github.com/falconry/falcon/issues/2387>`__) | ||
|
||
|
||
Misc | ||
---- | ||
|
||
- The printable PDF version of our documentation was enabled on Read the Docs. (`#2365 <https://github.com/falconry/falcon/issues/2365>`__) | ||
|
||
|
||
Contributors to this Release | ||
---------------------------- | ||
|
||
Many thanks to those who contributed to this bugfix release: | ||
|
||
- `AkshayAwate <https://github.com/AkshayAwate>`__ | ||
- `CaselIT <https://github.com/CaselIT>`__ | ||
- `chitvs <https://github.com/chitvs>`__ | ||
- `jap <https://github.com/jap>`__ | ||
- `vytas7 <https://github.com/vytas7>`__ |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ Changelogs | |
.. toctree:: | ||
|
||
4.1.0 <4.1.0> | ||
4.0.2 <4.0.2> | ||
4.0.1 <4.0.1> | ||
4.0.0 <4.0.0> | ||
3.1.3 <3.1.3> | ||
|
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
Oops, something went wrong.