Skip to content

Commit 717d7a5

Browse files
authored
Merge branch 'master' into fix/use-409-testing-doc
2 parents b48b47d + b2aa359 commit 717d7a5

632 files changed

Lines changed: 13844 additions & 2303 deletions

File tree

Some content is hidden

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

.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/actions/comment-docs-preview-in-pr/app/main.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import sys
33
from pathlib import Path
4-
from typing import Optional
4+
from typing import Union
55

66
import httpx
77
from github import Github
@@ -14,7 +14,7 @@
1414
class Settings(BaseSettings):
1515
github_repository: str
1616
github_event_path: Path
17-
github_event_name: Optional[str] = None
17+
github_event_name: Union[str, None] = None
1818
input_token: SecretStr
1919
input_deploy_url: str
2020

@@ -42,15 +42,13 @@ class PartialGithubEvent(BaseModel):
4242
except ValidationError as e:
4343
logging.error(f"Error parsing event file: {e.errors()}")
4444
sys.exit(0)
45-
use_pr: Optional[PullRequest] = None
45+
use_pr: Union[PullRequest, None] = None
4646
for pr in repo.get_pulls():
4747
if pr.head.sha == event.workflow_run.head_commit.id:
4848
use_pr = pr
4949
break
5050
if not use_pr:
51-
logging.error(
52-
f"No PR found for hash: {event.workflow_run.head_commit.id}"
53-
)
51+
logging.error(f"No PR found for hash: {event.workflow_run.head_commit.id}")
5452
sys.exit(0)
5553
github_headers = {
5654
"Authorization": f"token {settings.input_token.get_secret_value()}"

.github/actions/notify-translations/app/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
2+
import random
23
import time
34
from pathlib import Path
4-
import random
5-
from typing import Dict, Optional
5+
from typing import Dict, Union
66

77
import yaml
88
from github import Github
@@ -18,8 +18,8 @@ class Settings(BaseSettings):
1818
github_repository: str
1919
input_token: SecretStr
2020
github_event_path: Path
21-
github_event_name: Optional[str] = None
22-
input_debug: Optional[bool] = False
21+
github_event_name: Union[str, None] = None
22+
input_debug: Union[bool, None] = False
2323

2424

2525
class PartialGitHubEventIssue(BaseModel):
@@ -54,7 +54,7 @@ class PartialGitHubEvent(BaseModel):
5454
)
5555
if pr.state == "open":
5656
logging.debug(f"PR is open: {pr.number}")
57-
label_strs = set([label.name for label in pr.get_labels()])
57+
label_strs = {label.name for label in pr.get_labels()}
5858
if lang_all_label in label_strs and awaiting_label in label_strs:
5959
logging.info(
6060
f"This PR seems to be a language translation and awaiting reviews: {pr.number}"

.github/actions/notify-translations/app/translations.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ uk: 1748
88
tr: 1892
99
fr: 1972
1010
ko: 2017
11-
sq: 2041
11+
fa: 2041
1212
pl: 3169
1313
de: 3716
1414
id: 3717
1515
az: 3994
16+
nl: 4701
17+
uz: 4883
18+
sv: 5146
19+
he: 5157

.github/actions/people/app/main.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from collections import Counter, defaultdict
55
from datetime import datetime, timedelta, timezone
66
from pathlib import Path
7-
from typing import Container, DefaultDict, Dict, List, Optional, Set
7+
from typing import Container, DefaultDict, Dict, List, Set, Union
88

99
import httpx
1010
import yaml
@@ -14,7 +14,7 @@
1414
github_graphql_url = "https://api.github.com/graphql"
1515

1616
issues_query = """
17-
query Q($after: String) {
17+
query Q($after: String) {
1818
repository(name: "fastapi", owner: "tiangolo") {
1919
issues(first: 100, after: $after) {
2020
edges {
@@ -47,7 +47,7 @@
4747
"""
4848

4949
prs_query = """
50-
query Q($after: String) {
50+
query Q($after: String) {
5151
repository(name: "fastapi", owner: "tiangolo") {
5252
pullRequests(first: 100, after: $after) {
5353
edges {
@@ -133,7 +133,7 @@ class Author(BaseModel):
133133

134134
class CommentsNode(BaseModel):
135135
createdAt: datetime
136-
author: Optional[Author] = None
136+
author: Union[Author, None] = None
137137

138138

139139
class Comments(BaseModel):
@@ -142,7 +142,7 @@ class Comments(BaseModel):
142142

143143
class IssuesNode(BaseModel):
144144
number: int
145-
author: Optional[Author] = None
145+
author: Union[Author, None] = None
146146
title: str
147147
createdAt: datetime
148148
state: str
@@ -179,7 +179,7 @@ class Labels(BaseModel):
179179

180180

181181
class ReviewNode(BaseModel):
182-
author: Optional[Author] = None
182+
author: Union[Author, None] = None
183183
state: str
184184

185185

@@ -190,7 +190,7 @@ class Reviews(BaseModel):
190190
class PullRequestNode(BaseModel):
191191
number: int
192192
labels: Labels
193-
author: Optional[Author] = None
193+
author: Union[Author, None] = None
194194
title: str
195195
createdAt: datetime
196196
state: str
@@ -260,39 +260,41 @@ class Settings(BaseSettings):
260260
input_token: SecretStr
261261
input_standard_token: SecretStr
262262
github_repository: str
263+
httpx_timeout: int = 30
263264

264265

265266
def get_graphql_response(
266-
*, settings: Settings, query: str, after: Optional[str] = None
267+
*, settings: Settings, query: str, after: Union[str, None] = None
267268
):
268269
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
269270
variables = {"after": after}
270271
response = httpx.post(
271272
github_graphql_url,
272273
headers=headers,
274+
timeout=settings.httpx_timeout,
273275
json={"query": query, "variables": variables, "operationName": "Q"},
274276
)
275-
if not response.status_code == 200:
277+
if response.status_code != 200:
276278
logging.error(f"Response was not 200, after: {after}")
277279
logging.error(response.text)
278280
raise RuntimeError(response.text)
279281
data = response.json()
280282
return data
281283

282284

283-
def get_graphql_issue_edges(*, settings: Settings, after: Optional[str] = None):
285+
def get_graphql_issue_edges(*, settings: Settings, after: Union[str, None] = None):
284286
data = get_graphql_response(settings=settings, query=issues_query, after=after)
285287
graphql_response = IssuesResponse.parse_obj(data)
286288
return graphql_response.data.repository.issues.edges
287289

288290

289-
def get_graphql_pr_edges(*, settings: Settings, after: Optional[str] = None):
291+
def get_graphql_pr_edges(*, settings: Settings, after: Union[str, None] = None):
290292
data = get_graphql_response(settings=settings, query=prs_query, after=after)
291293
graphql_response = PRsResponse.parse_obj(data)
292294
return graphql_response.data.repository.pullRequests.edges
293295

294296

295-
def get_graphql_sponsor_edges(*, settings: Settings, after: Optional[str] = None):
297+
def get_graphql_sponsor_edges(*, settings: Settings, after: Union[str, None] = None):
296298
data = get_graphql_response(settings=settings, query=sponsors_query, after=after)
297299
graphql_response = SponsorsResponse.parse_obj(data)
298300
return graphql_response.data.user.sponsorshipsAsMaintainer.edges
@@ -501,9 +503,16 @@ def get_top_users(
501503
github_sponsors_path = Path("./docs/en/data/github_sponsors.yml")
502504
people_old_content = people_path.read_text(encoding="utf-8")
503505
github_sponsors_old_content = github_sponsors_path.read_text(encoding="utf-8")
504-
new_people_content = yaml.dump(people, sort_keys=False, width=200, allow_unicode=True)
505-
new_github_sponsors_content = yaml.dump(github_sponsors, sort_keys=False, width=200, allow_unicode=True)
506-
if people_old_content == new_people_content and github_sponsors_old_content == new_github_sponsors_content:
506+
new_people_content = yaml.dump(
507+
people, sort_keys=False, width=200, allow_unicode=True
508+
)
509+
new_github_sponsors_content = yaml.dump(
510+
github_sponsors, sort_keys=False, width=200, allow_unicode=True
511+
)
512+
if (
513+
people_old_content == new_people_content
514+
and github_sponsors_old_content == new_github_sponsors_content
515+
):
507516
logging.info("The FastAPI People data hasn't changed, finishing.")
508517
sys.exit(0)
509518
people_path.write_text(new_people_content, encoding="utf-8")
@@ -517,7 +526,9 @@ def get_top_users(
517526
logging.info(f"Creating a new branch {branch_name}")
518527
subprocess.run(["git", "checkout", "-b", branch_name], check=True)
519528
logging.info("Adding updated file")
520-
subprocess.run(["git", "add", str(people_path)], check=True)
529+
subprocess.run(
530+
["git", "add", str(people_path), str(github_sponsors_path)], check=True
531+
)
521532
logging.info("Committing updated file")
522533
message = "👥 Update FastAPI People"
523534
result = subprocess.run(["git", "commit", "-m", message], check=True)

.github/actions/watch-previews/app/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from datetime import datetime
33
from pathlib import Path
4-
from typing import List, Optional
4+
from typing import List, Union
55

66
import httpx
77
from github import Github
@@ -16,7 +16,7 @@ class Settings(BaseSettings):
1616
input_token: SecretStr
1717
github_repository: str
1818
github_event_path: Path
19-
github_event_name: Optional[str] = None
19+
github_event_name: Union[str, None] = None
2020

2121

2222
class Artifact(BaseModel):
@@ -74,7 +74,7 @@ def get_message(commit: str) -> str:
7474
logging.info(f"Docs preview was notified: {notified}")
7575
if not notified:
7676
artifact_name = f"docs-zip-{commit}"
77-
use_artifact: Optional[Artifact] = None
77+
use_artifact: Union[Artifact, None] = None
7878
for artifact in artifacts_response.artifacts:
7979
if artifact.name == artifact_name:
8080
use_artifact = artifact

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
commit-message:
9+
prefix:
10+
# Python
11+
- package-ecosystem: "pip"
12+
directory: "/"
13+
schedule:
14+
interval: "daily"
15+
commit-message:
16+
prefix:

.github/workflows/build-docs.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Build Docs
22
on:
33
push:
4+
branches:
5+
- master
46
pull_request:
57
types: [opened, synchronize]
68
jobs:
@@ -11,35 +13,35 @@ jobs:
1113
env:
1214
GITHUB_CONTEXT: ${{ toJson(github) }}
1315
run: echo "$GITHUB_CONTEXT"
14-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1517
- name: Set up Python
16-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v4
1719
with:
1820
python-version: "3.7"
19-
- uses: actions/cache@v2
21+
- uses: actions/cache@v3
2022
id: cache
2123
with:
2224
path: ${{ env.pythonLocation }}
23-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-docs-v2
25+
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v03
2426
- name: Install Flit
2527
if: steps.cache.outputs.cache-hit != 'true'
2628
run: python3.7 -m pip install flit
2729
- name: Install docs extras
2830
if: steps.cache.outputs.cache-hit != 'true'
2931
run: python3.7 -m flit install --deps production --extras doc
3032
- name: Install Material for MkDocs Insiders
31-
if: github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true'
33+
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
3234
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
3335
- name: Build Docs
3436
run: python3.7 ./scripts/docs.py build-all
3537
- name: Zip docs
3638
run: bash ./scripts/zip-docs.sh
37-
- uses: actions/upload-artifact@v2
39+
- uses: actions/upload-artifact@v3
3840
with:
3941
name: docs-zip
4042
path: ./docs.zip
4143
- name: Deploy to Netlify
42-
uses: nwtgck/actions-netlify@v1.1.5
44+
uses: nwtgck/actions-netlify@v1.2.3
4345
with:
4446
publish-dir: './site'
4547
production-branch: master

.github/workflows/latest-changes.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ 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

1919
jobs:
2020
latest-changes:
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v3
2424
with:
2525
# To allow latest-changes to commit to master
2626
token: ${{ secrets.ACTIONS_TOKEN }}

0 commit comments

Comments
 (0)