Skip to content

Commit

Permalink
Merge branch 'master' into Update-Chinese-translation-for-docs-zh-doc…
Browse files Browse the repository at this point in the history
…s-tutorial-request-files.md
  • Loading branch information
ASpathfinder committed May 12, 2022
2 parents 73e1c6c + 4bb8ac2 commit c88b1a7
Show file tree
Hide file tree
Showing 159 changed files with 651 additions and 409 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ body:
Thanks for your interest in FastAPI! 🚀
Please follow these instructions, fill every question, and do every step. 🙏
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
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.
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.
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 😅).
By asking questions in a structured way (following this) it will be much easier to help you.
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. 😎
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. 🤓
Expand Down Expand Up @@ -50,7 +50,7 @@ body:
label: Commit to Help
description: |
After submitting this, I commit to one of:
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
* 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.
* Implement a Pull Request for a confirmed bug.
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ body:
Thanks for your interest in FastAPI! 🚀
Please follow these instructions, fill every question, and do every step. 🙏
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
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.
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.
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 😅).
By asking questions in a structured way (following this) it will be much easier to help you.
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. 😎
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. 🤓
Expand Down Expand Up @@ -50,7 +50,7 @@ body:
label: Commit to Help
description: |
After submitting this, I commit to one of:
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
* 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.
* Implement a Pull Request for a confirmed bug.
Expand Down
4 changes: 1 addition & 3 deletions .github/actions/comment-docs-preview-in-pr/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class PartialGithubEvent(BaseModel):
use_pr = pr
break
if not use_pr:
logging.error(
f"No PR found for hash: {event.workflow_run.head_commit.id}"
)
logging.error(f"No PR found for hash: {event.workflow_run.head_commit.id}")
sys.exit(0)
github_headers = {
"Authorization": f"token {settings.input_token.get_secret_value()}"
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/notify-translations/app/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import random
import time
from pathlib import Path
import random
from typing import Dict, Optional

import yaml
Expand Down Expand Up @@ -54,7 +54,7 @@ class PartialGitHubEvent(BaseModel):
)
if pr.state == "open":
logging.debug(f"PR is open: {pr.number}")
label_strs = set([label.name for label in pr.get_labels()])
label_strs = {label.name for label in pr.get_labels()}
if lang_all_label in label_strs and awaiting_label in label_strs:
logging.info(
f"This PR seems to be a language translation and awaiting reviews: {pr.number}"
Expand Down
1 change: 1 addition & 0 deletions .github/actions/notify-translations/app/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ de: 3716
id: 3717
az: 3994
nl: 4701
uz: 4883
4 changes: 2 additions & 2 deletions .github/actions/people/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
github_graphql_url = "https://api.github.com/graphql"

issues_query = """
query Q($after: String) {
query Q($after: String) {
repository(name: "fastapi", owner: "tiangolo") {
issues(first: 100, after: $after) {
edges {
Expand Down Expand Up @@ -47,7 +47,7 @@
"""

prs_query = """
query Q($after: String) {
query Q($after: String) {
repository(name: "fastapi", owner: "tiangolo") {
pullRequests(first: 100, after: $after) {
edges {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: python3.7 -m flit install --deps production --extras doc
- name: Install Material for MkDocs Insiders
if: github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true'
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
- name: Build Docs
run: python3.7 ./scripts/docs.py build-all
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/latest-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
description: PR number
required: true
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/people.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_run:
workflows:
- Build Docs
types:
types:
- completed

jobs:
Expand Down
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-added-large-files
- id: check-toml
- id: check-yaml
args:
- --unsafe
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
hooks:
- id: pyupgrade
args:
- --py3-plus
- --keep-runtime-typing
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args:
- --recursive
- --in-place
- --remove-all-unused-imports
- --remove-unused-variables
- --expand-star-imports
- --exclude
- __init__.py
- --remove-duplicate-keys
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
6 changes: 4 additions & 2 deletions docs/az/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ theme:
name: material
custom_dir: overrides
palette:
- scheme: default
- media: "(prefers-color-scheme: light)"
scheme: default
primary: teal
accent: amber
toggle:
icon: material/lightbulb
name: Switch to light mode
- scheme: slate
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: teal
accent: amber
toggle:
Expand Down
4 changes: 2 additions & 2 deletions docs/de/docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Mit einer interaktiven API-Dokumentation und explorativen webbasierten Benutzers

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



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}.

Expand Down Expand Up @@ -193,7 +193,7 @@ Mit **FastAPI** bekommen Sie alle Funktionen von **Pydantic** (da FastAPI für d
* Gutes Zusammenspiel mit Ihrer/Ihrem **<abbr title="Integrierten Entwicklungsumgebung, ähnlich zu (Quellcode-)Editor">IDE</abbr>/<abbr title="Ein Programm, was Fehler im Quellcode sucht">linter</abbr>/Gehirn**:
* Weil Datenstrukturen von Pydantic einfach nur Instanzen ihrer definierten Klassen sind, sollten Autovervollständigung, Linting, mypy und ihre Intuition einwandfrei funktionieren.
* **Schnell**:
* In <a href="https://pydantic-docs.helpmanual.io/#benchmarks-tag" class="external-link" target="_blank">Vergleichen</a> ist Pydantic schneller als jede andere getestete Bibliothek.
* In <a href="https://pydantic-docs.helpmanual.io/benchmarks/" class="external-link" target="_blank">Vergleichen</a> ist Pydantic schneller als jede andere getestete Bibliothek.
* Validierung von **komplexen Strukturen**:
* Benutzung von hierachischen Pydantic Schemata, Python `typing`’s `List` und `Dict`, etc.
* Validierungen erlauben klare und einfache Datenschemadefinition, überprüft und dokumentiert als JSON Schema.
Expand Down
4 changes: 2 additions & 2 deletions docs/de/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ And now, go to <a href="http://127.0.0.1:8000/redoc" class="external-link" targe

### Recap

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

You do that with standard modern Python types.

Expand Down Expand Up @@ -378,7 +378,7 @@ Coming back to the previous code example, **FastAPI** will:
* As the `q` parameter is declared with `= None`, it is optional.
* Without the `None` it would be required (as is the body in the case with `PUT`).
* For `PUT` requests to `/items/{item_id}`, Read the body as JSON:
* Check that it has a required attribute `name` that should be a `str`.
* Check that it has a required attribute `name` that should be a `str`.
* Check that it has a required attribute `price` that has to be a `float`.
* Check that it has an optional attribute `is_offer`, that should be a `bool`, if present.
* All this would also work for deeply nested JSON objects.
Expand Down
6 changes: 4 additions & 2 deletions docs/de/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ theme:
name: material
custom_dir: overrides
palette:
- scheme: default
- media: "(prefers-color-scheme: light)"
scheme: default
primary: teal
accent: amber
toggle:
icon: material/lightbulb
name: Switch to light mode
- scheme: slate
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: teal
accent: amber
toggle:
Expand Down
12 changes: 10 additions & 2 deletions docs/en/data/external_links.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
articles:
english:
- author: Jean-Baptiste Rocher
author_link: https://hashnode.com/@jibrocher
link: https://dev.indooroutdoor.io/series/fastapi-react-poll-app
title: Building the Poll App From Django Tutorial With FastAPI And React
- author: Silvan Melchior
author_link: https://github.com/silvanmelchior
link: https://blog.devgenius.io/seamless-fastapi-configuration-with-confz-90949c14ea12
Expand Down Expand Up @@ -43,7 +47,7 @@ articles:
- author: Patrick Ladon
author_link: https://dev.to/factorlive
link: https://dev.to/factorlive/python-facebook-messenger-webhook-with-fastapi-on-glitch-4n90
title: Python Facebook messenger webhook with FastAPI on Glitch
title: Python Facebook messenger webhook with FastAPI on Glitch
- author: Dom Patmore
author_link: https://twitter.com/dompatmore
link: https://dompatmore.com/blog/authenticate-your-fastapi-app-with-auth0
Expand Down Expand Up @@ -204,7 +208,7 @@ articles:
author_link: https://medium.com/@williamhayes
link: https://medium.com/@williamhayes/fastapi-starlette-debug-vs-prod-5f7561db3a59
title: FastAPI/Starlette debug vs prod
- author: Mukul Mantosh
- author: Mukul Mantosh
author_link: https://twitter.com/MantoshMukul
link: https://www.jetbrains.com/pycharm/guide/tutorials/fastapi-aws-kubernetes/
title: Developing FastAPI Application using K8s & AWS
Expand All @@ -213,6 +217,10 @@ articles:
author_link: https://twitter.com/_nicoax
link: https://blog.codecentric.de/2019/08/inbetriebnahme-eines-scikit-learn-modells-mit-onnx-und-fastapi/
title: Inbetriebnahme eines scikit-learn-Modells mit ONNX und FastAPI
- author: Felix Schürmeyer
author_link: https://hellocoding.de/autor/felix-schuermeyer/
link: https://hellocoding.de/blog/coding-language/python/fastapi
title: REST-API Programmieren mittels Python und dem FastAPI Modul
japanese:
- author: '@bee2'
author_link: https://qiita.com/bee2
Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/advanced/additional-responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For example, to declare another response with a status code `404` and a Pydantic
**FastAPI** will take the Pydantic model from there, generate the `JSON Schema`, and put it in the correct place.

The correct place is:

* In the key `content`, that has as value another JSON object (`dict`) that contains:
* A key with the media type, e.g. `application/json`, that contains as value another JSON object, that contains:
* A key `schema`, that has as the value the JSON Schema from the model, here's the correct place.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/advanced/additional-status-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
When you return a `Response` directly, like in the example above, it will be returned directly.

It won't be serialized with a model, etc.

Make sure it has the data you want it to have, and that the values are valid JSON (if you are using `JSONResponse`).

!!! note "Technical Details"
Expand Down
4 changes: 2 additions & 2 deletions docs/en/docs/advanced/extending-openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ You can probably right-click each link and select an option similar to `Save lin

**Swagger UI** uses the files:

* <a href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@3/swagger-ui-bundle.js" class="external-link" target="_blank">`swagger-ui-bundle.js`</a>
* <a href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@3/swagger-ui.css" class="external-link" target="_blank">`swagger-ui.css`</a>
* <a href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui-bundle.js" class="external-link" target="_blank">`swagger-ui-bundle.js`</a>
* <a href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui.css" class="external-link" target="_blank">`swagger-ui.css`</a>

And **ReDoc** uses the file:

Expand Down
8 changes: 4 additions & 4 deletions docs/en/docs/advanced/security/oauth2-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ In this section you will see how to manage authentication and authorization with
You don't necessarily need OAuth2 scopes, and you can handle authentication and authorization however you want.

But OAuth2 with scopes can be nicely integrated into your API (with OpenAPI) and your API docs.

Nevertheless, you still enforce those scopes, or any other security/authorization requirement, however you need, in your code.

In many cases, OAuth2 with scopes can be an overkill.

But if you know you need it, or you are curious, keep reading.

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

It doesn't matter if it has other characters like `:` or if it is a URL.

Those details are implementation specific.

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

!!! note
You don't necessarily need to add different scopes in different places.

We are doing it here to demonstrate how **FastAPI** handles scopes declared at different levels.

```Python hl_lines="4 139 166"
Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/advanced/sql-databases-peewee.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Now let's check the file `sql_app/schemas.py`.
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.

These Pydantic models define more or less a "schema" (a valid data shape).

So this will help us avoiding confusion while using both.

### Create the Pydantic *models* / schemas
Expand Down
Loading

0 comments on commit c88b1a7

Please sign in to comment.