Skip to content

Commit 5ce771e

Browse files
authored
docs: apply assorted tweaks before 4.0.0b1 (#2357)
* docs: move frontpage quote example to a separate file * chore: actually add the new file * docs(REAME): disable cythonization of editable installs * docs: remove an empty line from quote.py * docs: fix a comment and add a note * chore(changes): aggregate 4.0 contributors so far
1 parent 91e90b5 commit 5ce771e

File tree

8 files changed

+42
-23
lines changed

8 files changed

+42
-23
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ listed below by date of first contribution:
198198
* Dave Tapley (davetapley)
199199
* Agustin Arce (aarcex3)
200200
* Christian Grossmüller (chgad)
201+
* Sai Prathik R (prathik2401)
201202

202203
(et al.)
203204

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ $ pip install -U ruff
3737
$ ruff format
3838
```
3939

40+
You can also reformat your code, and apply safe ``ruff`` fixes, via the
41+
``reformat`` ``tox`` environment:
42+
43+
```bash
44+
$ pip install -U tox
45+
$ tox -e reformat
46+
```
47+
4048
You can check all this by running ``tox`` from within the Falcon project directory.
4149
Your environment must be based on CPython 3.10, 3.11, 3.12 or 3.13:
4250

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ available to your app without having to reinstall the package:
278278
.. code:: bash
279279
280280
$ cd falcon
281-
$ pip install -e .
281+
$ FALCON_DISABLE_CYTHON=Y pip install -e .
282282
283283
You can manually test changes to the Falcon framework by switching to the
284284
directory of the cloned repo and then running pytest:

docs/changes/4.0.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ Many thanks to all of our talented and stylish contributors for this release!
101101
- `mgorny <https://github.com/mgorny>`__
102102
- `mihaitodor <https://github.com/mihaitodor>`__
103103
- `MRLab12 <https://github.com/MRLab12>`__
104+
- `myusko <https://github.com/myusko>`__
104105
- `nfsec <https://github.com/nfsec>`__
106+
- `prathik2401 <https://github.com/prathik2401>`__
105107
- `RioAtHome <https://github.com/RioAtHome>`__
106108
- `TigreModerata <https://github.com/TigreModerata>`__
107109
- `vgerak <https://github.com/vgerak>`__

docs/index.rst

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,8 @@ We like to think of Falcon as the *Dieter Rams* of web frameworks. Falcon
1616
encourages the REST architectural style, and tries to do as little as possible
1717
while remaining highly effective.
1818

19-
.. code:: python
20-
21-
import falcon
22-
23-
class QuoteResource:
24-
def on_get(self, req, resp):
25-
"""Handles GET requests"""
26-
quote = {
27-
'quote': (
28-
"I've always been more interested in "
29-
"the future than in the past."
30-
),
31-
'author': 'Grace Hopper'
32-
}
33-
34-
resp.media = quote
35-
36-
37-
app = falcon.App()
38-
app.add_route('/quote', QuoteResource())
19+
.. literalinclude:: ../examples/quote.py
20+
:language: python
3921

4022
For a fully working example, check out the :ref:`quickstart`.
4123

examples/quote.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import falcon
2+
3+
4+
class QuoteResource:
5+
def on_get(self, req: falcon.Request, resp: falcon.Response) -> None:
6+
"""Handle GET requests."""
7+
resp.media = {
8+
'quote': "I've always been more interested in the future than in the past.",
9+
'author': 'Grace Hopper',
10+
}
11+
12+
13+
app = falcon.App()
14+
app.add_route('/quote', QuoteResource())

falcon/util/mediatypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def match_score(self, media_type: _MediaType) -> Tuple[int, int, int, int, float
216216

217217
# PERF(vytas): It is possible to cache a classmethod too, but the invocation is
218218
# less efficient, especially in the case of a cache hit.
219-
# NOTE(vytas): Also, if we decide to make these classes public, we either need
220-
# to keep these cached parsers private, or to make sure we use frozen classes.
219+
# NOTE(vytas): Also, if we decide to make these classes public, we need to keep
220+
# these cached parsers private.
221221
_parse_media_type = functools.lru_cache(_MediaType.parse)
222222
_parse_media_range = functools.lru_cache(_MediaRange.parse)
223223

tests/test_examples.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
import falcon.testing as testing
1414

1515

16+
def test_quote(util):
17+
quote = util.load_module('examples/quote.py')
18+
19+
resp = testing.simulate_get(quote.app, '/quote')
20+
21+
assert resp.status_code == 200
22+
assert resp.json == {
23+
'author': 'Grace Hopper',
24+
'quote': "I've always been more interested in the future than in the past.",
25+
}
26+
27+
1628
def test_things(asgi, util):
1729
suffix = '_asgi' if asgi else ''
1830
things = util.load_module(f'examples/things{suffix}.py')

0 commit comments

Comments
 (0)