Skip to content

Commit 3d0f130

Browse files
authored
πŸ”§ Add pre-commit with first config and first formatting pass (fastapi#4888)
* πŸ”§ Add first pre-commit config * 🎨 Format YAML files with pre-commit * 🎨 Format Markdown with pre-commit * 🎨 Format SVGs, drawio, JS, HTML with pre-commit * βž• Add pre-commit to dev dependencies * ⬇️ Extend pre-commit range to support Python 3.6
1 parent 9cbd42b commit 3d0f130

File tree

119 files changed

+228
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+228
-221
lines changed

β€Ž.github/ISSUE_TEMPLATE/feature-request.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ body:
88
Thanks for your interest in FastAPI! πŸš€
99
1010
Please follow these instructions, fill every question, and do every step. πŸ™
11-
11+
1212
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
13-
13+
1414
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues.
1515
1616
All that, on top of all the incredible help provided by a bunch of community members, the [FastAPI Experts](https://fastapi.tiangolo.com/fastapi-people/#experts), that give a lot of their time to come here and help others.
1717
1818
That's a lot of work they are doing, but if more FastAPI users came to help others like them just a little bit more, it would be much less effort for them (and you and me πŸ˜…).
1919
2020
By asking questions in a structured way (following this) it will be much easier to help you.
21-
21+
2222
And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. 😎
2323
2424
As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. πŸ€“
@@ -50,7 +50,7 @@ body:
5050
label: Commit to Help
5151
description: |
5252
After submitting this, I commit to one of:
53-
53+
5454
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
5555
* I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
5656
* Implement a Pull Request for a confirmed bug.

β€Ž.github/ISSUE_TEMPLATE/question.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ body:
88
Thanks for your interest in FastAPI! πŸš€
99
1010
Please follow these instructions, fill every question, and do every step. πŸ™
11-
11+
1212
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
13-
13+
1414
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues.
1515
1616
All that, on top of all the incredible help provided by a bunch of community members, the [FastAPI Experts](https://fastapi.tiangolo.com/fastapi-people/#experts), that give a lot of their time to come here and help others.
1717
1818
That's a lot of work they are doing, but if more FastAPI users came to help others like them just a little bit more, it would be much less effort for them (and you and me πŸ˜…).
1919
2020
By asking questions in a structured way (following this) it will be much easier to help you.
21-
21+
2222
And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. 😎
2323
2424
As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. πŸ€“
@@ -50,7 +50,7 @@ body:
5050
label: Commit to Help
5151
description: |
5252
After submitting this, I commit to one of:
53-
53+
5454
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
5555
* I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
5656
* Implement a Pull Request for a confirmed bug.

β€Ž.github/workflows/latest-changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
description: PR number
1313
required: true
1414
debug_enabled:
15-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
15+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
1616
required: false
1717
default: false
1818

β€Ž.github/workflows/people.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77
inputs:
88
debug_enabled:
9-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
9+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
1010
required: false
1111
default: false
1212

β€Ž.github/workflows/preview-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_run:
44
workflows:
55
- Build Docs
6-
types:
6+
types:
77
- completed
88

99
jobs:

β€Ž.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.2.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-toml
9+
- id: check-yaml
10+
args:
11+
- --unsafe
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+

β€Ždocs/de/docs/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Mit einer interaktiven API-Dokumentation und explorativen webbasierten Benutzers
2727

2828
Alles basiert auf **Python 3.6 Typ**-Deklarationen (dank Pydantic). Es muss keine neue Syntax gelernt werden, nur standardisiertes modernes Python.
2929

30-
30+
3131

3232
Wenn Sie eine kurze, zweiminΓΌtige, Auffrischung in der Benutzung von Python Typ-Deklarationen benΓΆtigen (auch wenn Sie FastAPI nicht nutzen), schauen Sie sich diese kurze EinfΓΌhrung an (Englisch): Python Types{.internal-link target=_blank}.
3333

β€Ždocs/de/docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ And now, go to <a href="http://127.0.0.1:8000/redoc" class="external-link" targe
321321

322322
### Recap
323323

324-
In summary, you declare **once** the types of parameters, body, etc. as function parameters.
324+
In summary, you declare **once** the types of parameters, body, etc. as function parameters.
325325

326326
You do that with standard modern Python types.
327327

@@ -378,7 +378,7 @@ Coming back to the previous code example, **FastAPI** will:
378378
* As the `q` parameter is declared with `= None`, it is optional.
379379
* Without the `None` it would be required (as is the body in the case with `PUT`).
380380
* For `PUT` requests to `/items/{item_id}`, Read the body as JSON:
381-
* Check that it has a required attribute `name` that should be a `str`.
381+
* Check that it has a required attribute `name` that should be a `str`.
382382
* Check that it has a required attribute `price` that has to be a `float`.
383383
* Check that it has an optional attribute `is_offer`, that should be a `bool`, if present.
384384
* All this would also work for deeply nested JSON objects.

β€Ždocs/en/data/external_links.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ articles:
4747
- author: Patrick Ladon
4848
author_link: https://dev.to/factorlive
4949
link: https://dev.to/factorlive/python-facebook-messenger-webhook-with-fastapi-on-glitch-4n90
50-
title: Python Facebook messenger webhook with FastAPI on Glitch
50+
title: Python Facebook messenger webhook with FastAPI on Glitch
5151
- author: Dom Patmore
5252
author_link: https://twitter.com/dompatmore
5353
link: https://dompatmore.com/blog/authenticate-your-fastapi-app-with-auth0
@@ -208,7 +208,7 @@ articles:
208208
author_link: https://medium.com/@williamhayes
209209
link: https://medium.com/@williamhayes/fastapi-starlette-debug-vs-prod-5f7561db3a59
210210
title: FastAPI/Starlette debug vs prod
211-
- author: Mukul Mantosh
211+
- author: Mukul Mantosh
212212
author_link: https://twitter.com/MantoshMukul
213213
link: https://www.jetbrains.com/pycharm/guide/tutorials/fastapi-aws-kubernetes/
214214
title: Developing FastAPI Application using K8s & AWS

β€Ždocs/en/docs/advanced/additional-responses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ For example, to declare another response with a status code `404` and a Pydantic
3636
**FastAPI** will take the Pydantic model from there, generate the `JSON Schema`, and put it in the correct place.
3737

3838
The correct place is:
39-
39+
4040
* In the key `content`, that has as value another JSON object (`dict`) that contains:
4141
* A key with the media type, e.g. `application/json`, that contains as value another JSON object, that contains:
4242
* A key `schema`, that has as the value the JSON Schema from the model, here's the correct place.

β€Ždocs/en/docs/advanced/additional-status-codes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
2222
When you return a `Response` directly, like in the example above, it will be returned directly.
2323

2424
It won't be serialized with a model, etc.
25-
25+
2626
Make sure it has the data you want it to have, and that the values are valid JSON (if you are using `JSONResponse`).
2727

2828
!!! note "Technical Details"

β€Ždocs/en/docs/advanced/security/oauth2-scopes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ In this section you will see how to manage authentication and authorization with
1616
You don't necessarily need OAuth2 scopes, and you can handle authentication and authorization however you want.
1717

1818
But OAuth2 with scopes can be nicely integrated into your API (with OpenAPI) and your API docs.
19-
19+
2020
Nevertheless, you still enforce those scopes, or any other security/authorization requirement, however you need, in your code.
2121

2222
In many cases, OAuth2 with scopes can be an overkill.
23-
23+
2424
But if you know you need it, or you are curious, keep reading.
2525

2626
## OAuth2 scopes and OpenAPI
@@ -47,7 +47,7 @@ They are normally used to declare specific security permissions, for example:
4747
In OAuth2 a "scope" is just a string that declares a specific permission required.
4848

4949
It doesn't matter if it has other characters like `:` or if it is a URL.
50-
50+
5151
Those details are implementation specific.
5252

5353
For OAuth2 they are just strings.
@@ -115,7 +115,7 @@ In this case, it requires the scope `me` (it could require more than one scope).
115115

116116
!!! note
117117
You don't necessarily need to add different scopes in different places.
118-
118+
119119
We are doing it here to demonstrate how **FastAPI** handles scopes declared at different levels.
120120

121121
```Python hl_lines="4 139 166"

β€Ždocs/en/docs/advanced/sql-databases-peewee.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Now let's check the file `sql_app/schemas.py`.
182182
To avoid confusion between the Peewee *models* and the Pydantic *models*, we will have the file `models.py` with the Peewee models, and the file `schemas.py` with the Pydantic models.
183183

184184
These Pydantic models define more or less a "schema" (a valid data shape).
185-
185+
186186
So this will help us avoiding confusion while using both.
187187

188188
### Create the Pydantic *models* / schemas

β€Ždocs/en/docs/alternatives.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ It was one of the first extremely fast Python frameworks based on `asyncio`. It
235235

236236
!!! check "Inspired **FastAPI** to"
237237
Find a way to have a crazy performance.
238-
238+
239239
That's why **FastAPI** is based on Starlette, as it is the fastest framework available (tested by third-party benchmarks).
240240

241241
### <a href="https://falconframework.org/" class="external-link" target="_blank">Falcon</a>
@@ -333,7 +333,7 @@ Now APIStar is a set of tools to validate OpenAPI specifications, not a web fram
333333
Exist.
334334

335335
The idea of declaring multiple things (data validation, serialization and documentation) with the same Python types, that at the same time provided great editor support, was something I considered a brilliant idea.
336-
336+
337337
And after searching for a long time for a similar framework and testing many different alternatives, APIStar was the best option available.
338338

339339
Then APIStar stopped to exist as a server and Starlette was created, and was a new better foundation for such a system. That was the final inspiration to build **FastAPI**.
@@ -391,7 +391,7 @@ That's one of the main things that **FastAPI** adds on top, all based on Python
391391
Handle all the core web parts. Adding features on top.
392392

393393
The class `FastAPI` itself inherits directly from the class `Starlette`.
394-
394+
395395
So, anything that you can do with Starlette, you can do it directly with **FastAPI**, as it is basically Starlette on steroids.
396396

397397
### <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>

β€Ždocs/en/docs/deployment/docker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ If your FastAPI is a single file, for example, `main.py` without an `./app` dire
350350
Then you would just have to change the corresponding paths to copy the file inside the `Dockerfile`:
351351

352352
```{ .dockerfile .annotate hl_lines="10 13" }
353-
FROM python:3.9
353+
FROM python:3.9
354354

355355
WORKDIR /code
356356

β€Ždocs/en/docs/deployment/manually.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You can install an ASGI compatible server with:
3838

3939
!!! tip
4040
By adding the `standard`, Uvicorn will install and use some recommended extra dependencies.
41-
41+
4242
That including `uvloop`, the high-performance drop-in replacement for `asyncio`, that provides the big concurrency performance boost.
4343

4444
=== "Hypercorn"
@@ -89,7 +89,7 @@ You can then run your application the same way you have done in the tutorials, b
8989
Remember to remove the `--reload` option if you were using it.
9090

9191
The `--reload` option consumes much more resources, is more unstable, etc.
92-
92+
9393
It helps a lot during **development**, but you **shouldn't** use it in **production**.
9494

9595
## Hypercorn with Trio

β€Ždocs/en/docs/img/deployment/concepts/process-ram.drawio

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@
103103
</root>
104104
</mxGraphModel>
105105
</diagram>
106-
</mxfile>
106+
</mxfile>

0 commit comments

Comments
Β (0)