mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-11 07:28:11 -05:00
Compare commits
63 Commits
0.127.1
...
translatio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18de676729 | ||
|
|
c7f776407b | ||
|
|
d928bff07f | ||
|
|
cfc9b9430b | ||
|
|
e6a08f313d | ||
|
|
bf8507209a | ||
|
|
9a96763bad | ||
|
|
b08681fafd | ||
|
|
6fcc6054ff | ||
|
|
ce8a5ab91c | ||
|
|
f5112778d0 | ||
|
|
a8bf5871d7 | ||
|
|
5ca9472d8a | ||
|
|
5c50b3dd15 | ||
|
|
8c5f21c83c | ||
|
|
6b987b7262 | ||
|
|
50dd09a7b2 | ||
|
|
e076f651e7 | ||
|
|
badefaba9f | ||
|
|
5b812d4754 | ||
|
|
44b530168e | ||
|
|
6c50c68761 | ||
|
|
c42dd05cb8 | ||
|
|
aba58fc19d | ||
|
|
c70d79afe9 | ||
|
|
44f25ad0ac | ||
|
|
51df013955 | ||
|
|
7ff3dfb4fc | ||
|
|
9aa406d624 | ||
|
|
b3ad074153 | ||
|
|
e7fb2453ea | ||
|
|
f2687dc1bb | ||
|
|
862c3f4f94 | ||
|
|
052d6e86c2 | ||
|
|
31c7ffcdfe | ||
|
|
6854be9ebc | ||
|
|
258deb925d | ||
|
|
beff498743 | ||
|
|
0339277673 | ||
|
|
53d2453d1a | ||
|
|
d9b7b65b81 | ||
|
|
2c56706505 | ||
|
|
9ed5f246ed | ||
|
|
edf7995775 | ||
|
|
47391ea8fb | ||
|
|
3b1b4f034b | ||
|
|
f362fdc234 | ||
|
|
4ce34686d9 | ||
|
|
dbe83f3919 | ||
|
|
13743e115a | ||
|
|
52842fb8d3 | ||
|
|
4d4fb28f9f | ||
|
|
a1735d6d11 | ||
|
|
1b42639296 | ||
|
|
ded035a421 | ||
|
|
44c849c4fc | ||
|
|
8322a4445a | ||
|
|
4b2cfcfd34 | ||
|
|
e300630551 | ||
|
|
1b3bea8b6b | ||
|
|
34e884156f | ||
|
|
e15cff7376 | ||
|
|
844ded6b43 |
4
.github/workflows/translate.yml
vendored
4
.github/workflows/translate.yml
vendored
@@ -1,8 +1,8 @@
|
||||
name: Translate
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 5 15 * *" # Run at 05:00 on the 15 of every month
|
||||
# schedule:
|
||||
# - cron: "0 5 15 * *" # Run at 05:00 on the 15 of every month
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
|
||||
@@ -4,213 +4,197 @@ Translate to German (Deutsch).
|
||||
|
||||
Language code: de.
|
||||
|
||||
|
||||
### Definitions
|
||||
|
||||
"hyphen"
|
||||
The character «-»
|
||||
Unicode U+002D (HYPHEN-MINUS)
|
||||
Alternative names: hyphen, dash, minus sign
|
||||
|
||||
"dash"
|
||||
The character «–»
|
||||
Unicode U+2013 (EN DASH)
|
||||
German name: Halbgeviertstrich
|
||||
|
||||
|
||||
### Grammar to use when talking to the reader
|
||||
|
||||
Use the formal grammar (use «Sie» instead of «Du»).
|
||||
|
||||
Use the formal grammar (use `Sie` instead of `Du`).
|
||||
|
||||
### Quotes
|
||||
|
||||
1) Convert neutral double quotes («"») and English double typographic quotes («“» and «”») to German double typographic quotes («„» and «“»). Convert neutral single quotes («'») and English single typographic quotes («‘» and «’») to German single typographic quotes («‚» and «‘»). Do NOT convert «`"» to «„», do NOT convert «"`» to «“».
|
||||
1) Convert neutral double quotes (`"`) to German double typographic quotes (`„` and `“`). Convert neutral single quotes (`'`) to German single typographic quotes (`‚` and `‘`).
|
||||
|
||||
Do NOT convert quotes in code snippets and code blocks to their German typographic equivalents.
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
"Hello world"
|
||||
“Hello Universe”
|
||||
"He said: 'Hello'"
|
||||
“my name is ‘Nils’”
|
||||
`"__main__"`
|
||||
`"items"`
|
||||
»»»
|
||||
```
|
||||
"Hello world"
|
||||
“Hello Universe”
|
||||
"He said: 'Hello'"
|
||||
“my name is ‘Nils’”
|
||||
`"__main__"`
|
||||
`"items"`
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
„Hallo Welt“
|
||||
„Hallo Universum“
|
||||
„Er sagte: ‚Hallo‘“
|
||||
„Mein Name ist ‚Nils‘“
|
||||
`"__main__"`
|
||||
`"items"`
|
||||
»»»
|
||||
Result (German):
|
||||
|
||||
```
|
||||
„Hallo Welt“
|
||||
„Hallo Universum“
|
||||
„Er sagte: ‚Hallo‘“
|
||||
„Mein Name ist ‚Nils‘“
|
||||
`"__main__"`
|
||||
`"items"`
|
||||
```
|
||||
|
||||
### Ellipsis
|
||||
|
||||
1) Make sure there is a space between an ellipsis and a word following or preceding the ellipsis.
|
||||
- Make sure there is a space between an ellipsis and a word following or preceding the ellipsis.
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
...as we intended.
|
||||
...this would work:
|
||||
...etc.
|
||||
others...
|
||||
More to come...
|
||||
»»»
|
||||
```
|
||||
...as we intended.
|
||||
...this would work:
|
||||
...etc.
|
||||
others...
|
||||
More to come...
|
||||
```
|
||||
|
||||
Result (German):
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
... wie wir es beabsichtigt hatten.
|
||||
... das würde funktionieren:
|
||||
... usw.
|
||||
Andere ...
|
||||
Später mehr ...
|
||||
»»»
|
||||
|
||||
2) This does not apply in URLs, code blocks, and code snippets. Do not remove or add spaces there.
|
||||
```
|
||||
... wie wir es beabsichtigt hatten.
|
||||
... das würde funktionieren:
|
||||
... usw.
|
||||
Andere ...
|
||||
Später mehr ...
|
||||
```
|
||||
|
||||
- This does not apply in URLs, code blocks, and code snippets. Do not remove or add spaces there.
|
||||
|
||||
### Headings
|
||||
|
||||
1) Translate headings using the infinite form.
|
||||
- Translate headings using the infinite form.
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
## Create a Project { #create-a-project }
|
||||
»»»
|
||||
```
|
||||
## Create a Project { #create-a-project }
|
||||
```
|
||||
|
||||
Translate with (German):
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
## Ein Projekt erstellen { #create-a-project }
|
||||
»»»
|
||||
```
|
||||
## Ein Projekt erstellen { #create-a-project }
|
||||
```
|
||||
|
||||
Do NOT translate with (German):
|
||||
Do NOT translate with (German):
|
||||
|
||||
«««
|
||||
## Erstellen Sie ein Projekt { #create-a-project }
|
||||
»»»
|
||||
```
|
||||
## Erstellen Sie ein Projekt { #create-a-project }
|
||||
```
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
# Install Packages { #install-packages }
|
||||
»»»
|
||||
```
|
||||
# Install Packages { #install-packages }
|
||||
```
|
||||
|
||||
Translate with (German):
|
||||
Translate with (German):
|
||||
|
||||
«««
|
||||
# Pakete installieren { #install-packages }
|
||||
»»»
|
||||
```
|
||||
# Pakete installieren { #install-packages }
|
||||
```
|
||||
|
||||
Do NOT translate with (German):
|
||||
Do NOT translate with (German):
|
||||
|
||||
«««
|
||||
# Installieren Sie Pakete { #install-packages }
|
||||
»»»
|
||||
```
|
||||
# Installieren Sie Pakete { #install-packages }
|
||||
```
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
### Run Your Program { #run-your-program }
|
||||
»»»
|
||||
```
|
||||
### Run Your Program { #run-your-program }
|
||||
```
|
||||
|
||||
Translate with (German):
|
||||
Translate with (German):
|
||||
|
||||
«««
|
||||
### Ihr Programm ausführen { #run-your-program }
|
||||
»»»
|
||||
```
|
||||
### Ihr Programm ausführen { #run-your-program }
|
||||
```
|
||||
|
||||
Do NOT translate with (German):
|
||||
Do NOT translate with (German):
|
||||
|
||||
«««
|
||||
### Führen Sie Ihr Programm aus { #run-your-program }
|
||||
»»»
|
||||
```
|
||||
### Führen Sie Ihr Programm aus { #run-your-program }
|
||||
```
|
||||
|
||||
2) Make sure that the translated part of the heading does not end with a period.
|
||||
- Make sure that the translated part of the heading does not end with a period.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
## Another module with `APIRouter` { #another-module-with-apirouter }
|
||||
»»»
|
||||
```
|
||||
## Another module with `APIRouter` { #another-module-with-apirouter }
|
||||
```
|
||||
|
||||
Translate with (German):
|
||||
Translate with (German):
|
||||
|
||||
«««
|
||||
## Ein weiteres Modul mit `APIRouter` { #another-module-with-apirouter }
|
||||
»»»
|
||||
```
|
||||
## Ein weiteres Modul mit `APIRouter` { #another-module-with-apirouter }
|
||||
```
|
||||
|
||||
Do NOT translate with (German) – notice the added period:
|
||||
Do NOT translate with (German) – notice the added period:
|
||||
|
||||
«««
|
||||
## Ein weiteres Modul mit `APIRouter`. { #another-module-with-apirouter }
|
||||
»»»
|
||||
```
|
||||
## Ein weiteres Modul mit `APIRouter`. { #another-module-with-apirouter }
|
||||
```
|
||||
|
||||
3) Replace occurrences of literal « - » (a space followed by a hyphen followed by a space) with « – » (a space followed by a dash followed by a space) in the translated part of the heading.
|
||||
- Replace occurrences of literal ` - ` (a space followed by a hyphen followed by a space) with ` – ` (a space followed by a dash followed by a space) in the translated part of the heading.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
# FastAPI in Containers - Docker { #fastapi-in-containers-docker }
|
||||
»»»
|
||||
```
|
||||
# FastAPI in Containers - Docker { #fastapi-in-containers-docker }
|
||||
```
|
||||
|
||||
Translate with (German) – notice the dash:
|
||||
Translate with (German) – notice the dash:
|
||||
|
||||
«««
|
||||
# FastAPI in Containern – Docker { #fastapi-in-containers-docker }
|
||||
»»»
|
||||
```
|
||||
# FastAPI in Containern – Docker { #fastapi-in-containers-docker }
|
||||
```
|
||||
|
||||
Do NOT translate with (German) – notice the hyphen:
|
||||
Do NOT translate with (German) – notice the hyphen:
|
||||
|
||||
«««
|
||||
# FastAPI in Containern - Docker { #fastapi-in-containers-docker }
|
||||
»»»
|
||||
```
|
||||
# FastAPI in Containern - Docker { #fastapi-in-containers-docker }
|
||||
```
|
||||
|
||||
3.1) Do not apply rule 3 when there is no space before or no space after the hyphen.
|
||||
- Do not apply rule 3 when there is no space before or no space after the hyphen.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
## Type hints and annotations { #type-hints-and-annotations }
|
||||
»»»
|
||||
```
|
||||
## Type hints and annotations { #type-hints-and-annotations }
|
||||
```
|
||||
|
||||
Translate with (German) – notice the hyphen:
|
||||
Translate with (German) - notice the hyphen:
|
||||
|
||||
«««
|
||||
## Typhinweise und -annotationen { #type-hints-and-annotations }
|
||||
»»»
|
||||
```
|
||||
## Typhinweise und -annotationen { #type-hints-and-annotations }
|
||||
```
|
||||
|
||||
Do NOT translate with (German) – notice the dash:
|
||||
Do NOT translate with (German) - notice the dash:
|
||||
|
||||
«««
|
||||
## Typhinweise und –annotationen { #type-hints-and-annotations }
|
||||
»»»
|
||||
```
|
||||
## Typhinweise und –annotationen { #type-hints-and-annotations }
|
||||
```
|
||||
|
||||
3.2) Do not apply rule 3 to the untranslated part of the heading inside curly brackets, which you shall not translate.
|
||||
- Do not modify the hyphens in the content in headers inside of curly braces, which you shall not translate.
|
||||
|
||||
|
||||
### German instructions, when to use and when not to use hyphens in words (written in first person, which is you)
|
||||
### German instructions, when to use and when not to use hyphens in words (written in first person, which is you).
|
||||
|
||||
In der Regel versuche ich so weit wie möglich Worte zusammenzuschreiben, also ohne Bindestrich, es sei denn, es ist Konkretesding-Klassevondingen, etwa «Pydantic-Modell» (aber: «Datenbankmodell»), «Python-Modul» (aber: «Standardmodul»). Ich setze auch einen Bindestrich, wenn er die gleichen Buchstaben verbindet, etwa «Enum-Member», «Cloud-Dienst», «Template-Engine». Oder wenn das Wort sonst einfach zu lang wird, etwa, «Performance-Optimierung». Oder um etwas visuell besser zu dokumentieren, etwa «Pfadoperation-Dekorator», «Pfadoperation-Funktion».
|
||||
|
||||
@@ -219,123 +203,122 @@ In der Regel versuche ich so weit wie möglich Worte zusammenzuschreiben, also o
|
||||
|
||||
Ich versuche nicht, alles einzudeutschen. Das bezieht sich besonders auf Begriffe aus dem Bereich der Programmierung. Ich wandele zwar korrekt in Großschreibung um und setze Bindestriche, wo notwendig, aber ansonsten lasse ich solch ein Wort unverändert. Beispielsweise wird aus dem englischen Wort «string» in der deutschen Übersetzung «String», aber nicht «Zeichenkette». Oder aus dem englischen Wort «request body» wird in der deutschen Übersetzung «Requestbody», aber nicht «Anfragekörper». Oder aus dem englischen «response» wird im Deutschen «Response», aber nicht «Antwort».
|
||||
|
||||
|
||||
### List of English terms and their preferred German translations
|
||||
|
||||
Below is a list of English terms and their preferred German translations, separated by a colon («:»). Use these translations, do not use your own. If an existing translation does not use these terms, update it to use them. In the below list, a term or a translation may be followed by an explanation in brackets, which explains when to translate the term this way. If a translation is preceded by «NOT», then that means: do NOT use this translation for this term. English nouns, starting with the word «the», have the German genus – «der», «die», «das» – prepended to their German translation, to help you to grammatically decline them in the translation. They are given in singular case, unless they have «(plural)» attached, which means they are given in plural case. Verbs are given in the full infinitive – starting with the word «to».
|
||||
Below is a list of English terms and their preferred German translations, separated by a colon (:). Use these translations, do not use your own. If an existing translation does not use these terms, update it to use them. In the below list, a term or a translation may be followed by an explanation in brackets, which explains when to translate the term this way. If a translation is preceded by `NOT`, then that means: do NOT use this translation for this term. English nouns, starting with the word `the`, have the German genus – `der`, `die`, `das` – prepended to their German translation, to help you to grammatically decline them in the translation. They are given in singular case, unless they have `(plural)` attached, which means they are given in plural case. Verbs are given in the full infinitive – starting with the word `to`.
|
||||
|
||||
* «/// check»: «/// check | Testen»
|
||||
* «/// danger»: «/// danger | Gefahr»
|
||||
* «/// info»: «/// info | Info»
|
||||
* «/// note | Technical Details»: «/// note | Technische Details»
|
||||
* «/// note»: «/// note | Hinweis»
|
||||
* «/// tip»: «/// tip | Tipp»
|
||||
* «/// warning»: «/// warning | Achtung»
|
||||
* «you»: «Sie»
|
||||
* «your»: «Ihr»
|
||||
* «e.g»: «z. B.»
|
||||
* «etc.»: «usw.»
|
||||
* «ref»: «Ref.»
|
||||
* «the Tutorial - User guide»: «das Tutorial – Benutzerhandbuch»
|
||||
* «the Advanced User Guide»: «das Handbuch für fortgeschrittene Benutzer»
|
||||
* «the SQLModel docs»: «die SQLModel-Dokumentation»
|
||||
* «the docs»: «die Dokumentation» (use singular case)
|
||||
* «the env var»: «die Umgebungsvariable»
|
||||
* «the `PATH` environment variable»: «die `PATH`-Umgebungsvariable»
|
||||
* «the `PATH`»: «der `PATH`»
|
||||
* «the `requirements.txt`»: «die `requirements.txt`»
|
||||
* «the API Router»: «der API-Router»
|
||||
* «the Authorization-Header»: «der Autorisierungsheader»
|
||||
* «the `Authorization`-Header»: «der `Authorization`-Header»
|
||||
* «the background task»: «der Hintergrundtask»
|
||||
* «the button»: «der Button»
|
||||
* «the cloud provider»: «der Cloudanbieter»
|
||||
* «the CLI»: «Das CLI»
|
||||
* «the coverage»: «Die Testabdeckung»
|
||||
* «the command line interface»: «Das Kommandozeileninterface»
|
||||
* «the default value»: «der Defaultwert»
|
||||
* «the default value»: NOT «der Standardwert»
|
||||
* «the default declaration»: «die Default-Deklaration»
|
||||
* «the deployment»: «das Deployment»
|
||||
* «the dict»: «das Dict»
|
||||
* «the dictionary»: «das Dictionary»
|
||||
* «the enumeration»: «die Enumeration»
|
||||
* «the enum»: «das Enum»
|
||||
* «the engine»: «die Engine»
|
||||
* «the error response»: «die Error-Response»
|
||||
* «the event»: «das Event»
|
||||
* «the exception»: «die Exception»
|
||||
* «the exception handler»: «der Exceptionhandler»
|
||||
* «the form model»: «das Formularmodell»
|
||||
* «the form body»: «der Formularbody»
|
||||
* «the header»: «der Header»
|
||||
* «the headers» (plural): «die Header»
|
||||
* «in headers» (plural): «in Headern»
|
||||
* «the forwarded header»: «der Forwarded-Header»
|
||||
* «the lifespan event»: «das Lifespan-Event»
|
||||
* «the lock»: «der Lock»
|
||||
* «the locking»: «das Locking»
|
||||
* «the mobile application»: «die Mobile-Anwendung»
|
||||
* «the model object»: «das Modellobjekt»
|
||||
* «the mounting»: «das Mounten»
|
||||
* «mounted»: «gemountet»
|
||||
* «the origin»: «das Origin»
|
||||
* «the override»: «Die Überschreibung»
|
||||
* «the parameter»: «der Parameter»
|
||||
* «the parameters» (plural): «die Parameter»
|
||||
* «the function parameter»: «der Funktionsparameter»
|
||||
* «the default parameter»: «der Defaultparameter»
|
||||
* «the body parameter»: «der Body-Parameter»
|
||||
* «the request body parameter»: «der Requestbody-Parameter»
|
||||
* «the path parameter»: «der Pfad-Parameter»
|
||||
* «the query parameter»: «der Query-Parameter»
|
||||
* «the cookie parameter»: «der Cookie-Parameter»
|
||||
* «the header parameter»: «der Header-Parameter»
|
||||
* «the form parameter»: «der Formular-Parameter»
|
||||
* «the payload»: «die Payload»
|
||||
* «the performance»: NOT «die Performance»
|
||||
* «the query»: «die Query»
|
||||
* «the recap»: «die Zusammenfassung»
|
||||
* «the request» (what the client sends to the server): «der Request»
|
||||
* «the request body»: «der Requestbody»
|
||||
* «the request bodies» (plural): «die Requestbodys»
|
||||
* «the response» (what the server sends back to the client): «die Response»
|
||||
* «the return type»: «der Rückgabetyp»
|
||||
* «the return value»: «der Rückgabewert»
|
||||
* «the startup» (the event of the app): «der Startup»
|
||||
* «the shutdown» (the event of the app): «der Shutdown»
|
||||
* «the startup event»: «das Startup-Event»
|
||||
* «the shutdown event»: «das Shutdown-Event»
|
||||
* «the startup» (of the server): «das Hochfahren»
|
||||
* «the startup» (the company): «das Startup»
|
||||
* «the SDK»: «das SDK»
|
||||
* «the tag»: «der Tag»
|
||||
* «the type annotation»: «die Typannotation»
|
||||
* «the type hint»: «der Typhinweis»
|
||||
* «the wildcard»: «die Wildcard»
|
||||
* «the worker class»: «die Workerklasse»
|
||||
* «the worker class»: NOT «die Arbeiterklasse»
|
||||
* «the worker process»: «der Workerprozess»
|
||||
* «the worker process»: NOT «der Arbeiterprozess»
|
||||
* «to commit»: «committen»
|
||||
* «to deploy» (in the cloud): «deployen»
|
||||
* «to modify»: «ändern»
|
||||
* «to serve» (an application): «bereitstellen»
|
||||
* «to serve» (a response): «ausliefern»
|
||||
* «to serve»: NOT «bedienen»
|
||||
* «to upgrade»: «aktualisieren»
|
||||
* «to wrap»: «wrappen»
|
||||
* «to wrap»: NOT «hüllen»
|
||||
* «`foo` as a `type`»: «`foo` vom Typ `type`»
|
||||
* «`foo` as a `type`»: «`foo`, ein `type`»
|
||||
* «FastAPI's X»: «FastAPIs X»
|
||||
* «Starlette's Y»: «Starlettes Y»
|
||||
* «X is case-sensitive»: «Groß-/Kleinschreibung ist relevant in X»
|
||||
* «X is case-insensitive»: «Groß-/Kleinschreibung ist nicht relevant in X»
|
||||
* «standard Python»: «Standard-Python»
|
||||
* «deprecated»: «deprecatet»
|
||||
* /// check: /// check | Testen
|
||||
* /// danger: /// danger | Gefahr
|
||||
* /// info: /// info | Info
|
||||
* /// note | Technical Details: /// note | Technische Details
|
||||
* /// note: /// note | Hinweis
|
||||
* /// tip: /// tip | Tipp
|
||||
* /// warning: /// warning | Achtung
|
||||
* you: Sie
|
||||
* your: Ihr
|
||||
* e.g: z. B.
|
||||
* etc.: usw.
|
||||
* ref: Ref.
|
||||
* the Tutorial - User guide: das Tutorial – Benutzerhandbuch
|
||||
* the Advanced User Guide: das Handbuch für fortgeschrittene Benutzer
|
||||
* the SQLModel docs: die SQLModel-Dokumentation
|
||||
* the docs: die Dokumentation (use singular case)
|
||||
* the env var: die Umgebungsvariable
|
||||
* the `PATH` environment variable: die `PATH`-Umgebungsvariable
|
||||
* the `PATH`: der `PATH`
|
||||
* the `requirements.txt`: die `requirements.txt`
|
||||
* the API Router: der API-Router
|
||||
* the Authorization-Header: der Autorisierungsheader
|
||||
* the `Authorization`-Header: der `Authorization`-Header
|
||||
* the background task: der Hintergrundtask
|
||||
* the button: der Button
|
||||
* the cloud provider: der Cloudanbieter
|
||||
* the CLI: Das CLI
|
||||
* the coverage: Die Testabdeckung
|
||||
* the command line interface: Das Kommandozeileninterface
|
||||
* the default value: der Defaultwert
|
||||
* the default value: NOT der Standardwert
|
||||
* the default declaration: die Default-Deklaration
|
||||
* the deployment: das Deployment
|
||||
* the dict: das Dict
|
||||
* the dictionary: das Dictionary
|
||||
* the enumeration: die Enumeration
|
||||
* the enum: das Enum
|
||||
* the engine: die Engine
|
||||
* the error response: die Error-Response
|
||||
* the event: das Event
|
||||
* the exception: die Exception
|
||||
* the exception handler: der Exceptionhandler
|
||||
* the form model: das Formularmodell
|
||||
* the form body: der Formularbody
|
||||
* the header: der Header
|
||||
* the headers (plural): die Header
|
||||
* in headers (plural): in Headern
|
||||
* the forwarded header: der Forwarded-Header
|
||||
* the lifespan event: das Lifespan-Event
|
||||
* the lock: der Lock
|
||||
* the locking: das Locking
|
||||
* the mobile application: die Mobile-Anwendung
|
||||
* the model object: das Modellobjekt
|
||||
* the mounting: das Mounten
|
||||
* mounted: gemountet
|
||||
* the origin: das Origin
|
||||
* the override: Die Überschreibung
|
||||
* the parameter: der Parameter
|
||||
* the parameters (plural): die Parameter
|
||||
* the function parameter: der Funktionsparameter
|
||||
* the default parameter: der Defaultparameter
|
||||
* the body parameter: der Body-Parameter
|
||||
* the request body parameter: der Requestbody-Parameter
|
||||
* the path parameter: der Pfad-Parameter
|
||||
* the query parameter: der Query-Parameter
|
||||
* the cookie parameter: der Cookie-Parameter
|
||||
* the header parameter: der Header-Parameter
|
||||
* the form parameter: der Formular-Parameter
|
||||
* the payload: die Payload
|
||||
* the performance: NOT die Performance
|
||||
* the query: die Query
|
||||
* the recap: die Zusammenfassung
|
||||
* the request (what the client sends to the server): der Request
|
||||
* the request body: der Requestbody
|
||||
* the request bodies (plural): die Requestbodys
|
||||
* the response (what the server sends back to the client): die Response
|
||||
* the return type: der Rückgabetyp
|
||||
* the return value: der Rückgabewert
|
||||
* the startup (the event of the app): der Startup
|
||||
* the shutdown (the event of the app): der Shutdown
|
||||
* the startup event: das Startup-Event
|
||||
* the shutdown event: das Shutdown-Event
|
||||
* the startup (of the server): das Hochfahren
|
||||
* the startup (the company): das Startup
|
||||
* the SDK: das SDK
|
||||
* the tag: der Tag
|
||||
* the type annotation: die Typannotation
|
||||
* the type hint: der Typhinweis
|
||||
* the wildcard: die Wildcard
|
||||
* the worker class: die Workerklasse
|
||||
* the worker class: NOT die Arbeiterklasse
|
||||
* the worker process: der Workerprozess
|
||||
* the worker process: NOT der Arbeiterprozess
|
||||
* to commit: committen
|
||||
* to deploy (in the cloud): deployen
|
||||
* to modify: ändern
|
||||
* to serve (an application): bereitstellen
|
||||
* to serve (a response): ausliefern
|
||||
* to serve: NOT bedienen
|
||||
* to upgrade: aktualisieren
|
||||
* to wrap: wrappen
|
||||
* to wrap: NOT hüllen
|
||||
* `foo` as a `type`: `foo` vom Typ `type`
|
||||
* `foo` as a `type`: `foo`, ein `type`
|
||||
* FastAPI's X: FastAPIs X
|
||||
* Starlette's Y: Starlettes Y
|
||||
* X is case-sensitive: Groß-/Kleinschreibung ist relevant in X
|
||||
* X is case-insensitive: Groß-/Kleinschreibung ist nicht relevant in X
|
||||
* standard Python: Standard-Python
|
||||
* deprecated: deprecatet
|
||||
|
||||
|
||||
### Other rules
|
||||
|
||||
Preserve indentation. Keep emoticons. Encode in utf-8. Use Linux line breaks (LF).
|
||||
Preserve indentation. Keep emojis. Encode in utf-8. Use Linux line breaks (LF).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tiangolo:
|
||||
login: tiangolo
|
||||
count: 808
|
||||
count: 857
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
dependabot:
|
||||
@@ -10,7 +10,7 @@ dependabot:
|
||||
url: https://github.com/apps/dependabot
|
||||
alejsdev:
|
||||
login: alejsdev
|
||||
count: 52
|
||||
count: 53
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/90076947?u=85ceac49fb87138aebe8d663912e359447329090&v=4
|
||||
url: https://github.com/alejsdev
|
||||
pre-commit-ci:
|
||||
@@ -18,6 +18,11 @@ pre-commit-ci:
|
||||
count: 50
|
||||
avatarUrl: https://avatars.githubusercontent.com/in/68672?v=4
|
||||
url: https://github.com/apps/pre-commit-ci
|
||||
YuriiMotov:
|
||||
login: YuriiMotov
|
||||
count: 36
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=b9b13d598dddfab529a52d264df80a900bfe7060&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
github-actions:
|
||||
login: github-actions
|
||||
count: 26
|
||||
@@ -28,26 +33,21 @@ Kludex:
|
||||
count: 25
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
YuriiMotov:
|
||||
login: YuriiMotov
|
||||
count: 20
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=b9b13d598dddfab529a52d264df80a900bfe7060&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
dmontagu:
|
||||
login: dmontagu
|
||||
count: 17
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/35119617?u=540f30c937a6450812628b9592a1dfe91bbe148e&v=4
|
||||
url: https://github.com/dmontagu
|
||||
svlandeg:
|
||||
login: svlandeg
|
||||
count: 16
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8796347?u=556c97650c27021911b0b9447ec55e75987b0e8a&v=4
|
||||
url: https://github.com/svlandeg
|
||||
nilslindemann:
|
||||
login: nilslindemann
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6892179?u=1dca6a22195d6cd1ab20737c0e19a4c55d639472&v=4
|
||||
url: https://github.com/nilslindemann
|
||||
svlandeg:
|
||||
login: svlandeg
|
||||
count: 14
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8796347?u=556c97650c27021911b0b9447ec55e75987b0e8a&v=4
|
||||
url: https://github.com/svlandeg
|
||||
euri10:
|
||||
login: euri10
|
||||
count: 13
|
||||
@@ -553,6 +553,11 @@ DanielKusyDev:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/36250676?u=2ea6114ff751fc48b55f231987a0e2582c6b1bd2&v=4
|
||||
url: https://github.com/DanielKusyDev
|
||||
Viicos:
|
||||
login: Viicos
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/65306057?u=fcd677dc1b9bef12aa103613e5ccb3f8ce305af9&v=4
|
||||
url: https://github.com/Viicos
|
||||
DanielYang59:
|
||||
login: DanielYang59
|
||||
count: 2
|
||||
|
||||
@@ -2,57 +2,51 @@ sponsors:
|
||||
- - login: renderinc
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/36424661?v=4
|
||||
url: https://github.com/renderinc
|
||||
- login: andrew-propelauth
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/89474256?u=c98993dec8553c09d424ede67bbe86e5c35f48c9&v=4
|
||||
url: https://github.com/andrew-propelauth
|
||||
- login: blockbee-io
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/115143449?u=1b8620c2d6567c4df2111a371b85a51f448f9b85&v=4
|
||||
url: https://github.com/blockbee-io
|
||||
- login: zuplo
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/85497839?v=4
|
||||
url: https://github.com/zuplo
|
||||
- login: coderabbitai
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/132028505?v=4
|
||||
url: https://github.com/coderabbitai
|
||||
- login: greptileai
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/140149887?v=4
|
||||
url: https://github.com/greptileai
|
||||
- login: subtotal
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/176449348?v=4
|
||||
url: https://github.com/subtotal
|
||||
- login: greptileai
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/140149887?v=4
|
||||
url: https://github.com/greptileai
|
||||
- login: coderabbitai
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/132028505?v=4
|
||||
url: https://github.com/coderabbitai
|
||||
- login: zuplo
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/85497839?v=4
|
||||
url: https://github.com/zuplo
|
||||
- login: blockbee-io
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/115143449?u=1b8620c2d6567c4df2111a371b85a51f448f9b85&v=4
|
||||
url: https://github.com/blockbee-io
|
||||
- login: andrew-propelauth
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/89474256?u=c98993dec8553c09d424ede67bbe86e5c35f48c9&v=4
|
||||
url: https://github.com/andrew-propelauth
|
||||
- login: railwayapp
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/66716858?v=4
|
||||
url: https://github.com/railwayapp
|
||||
- - login: dribia
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/41189616?v=4
|
||||
url: https://github.com/dribia
|
||||
- login: svix
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/80175132?v=4
|
||||
url: https://github.com/svix
|
||||
- - login: speakeasy-api
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/91446104?v=4
|
||||
url: https://github.com/speakeasy-api
|
||||
- login: stainless-api
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/88061651?v=4
|
||||
url: https://github.com/stainless-api
|
||||
- login: speakeasy-api
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/91446104?v=4
|
||||
url: https://github.com/speakeasy-api
|
||||
- login: databento
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/64141749?v=4
|
||||
url: https://github.com/databento
|
||||
- login: svix
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/80175132?v=4
|
||||
url: https://github.com/svix
|
||||
- login: permitio
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/71775833?v=4
|
||||
url: https://github.com/permitio
|
||||
- - login: Ponte-Energy-Partners
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/114745848?v=4
|
||||
url: https://github.com/Ponte-Energy-Partners
|
||||
- login: LambdaTest-Inc
|
||||
- login: databento
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/64141749?v=4
|
||||
url: https://github.com/databento
|
||||
- - login: LambdaTest-Inc
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/171592363?u=96606606a45fa170427206199014f2a5a2a4920b&v=4
|
||||
url: https://github.com/LambdaTest-Inc
|
||||
- login: Ponte-Energy-Partners
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/114745848?v=4
|
||||
url: https://github.com/Ponte-Energy-Partners
|
||||
- login: BoostryJP
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/57932412?v=4
|
||||
url: https://github.com/BoostryJP
|
||||
- login: requestly
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/12287519?v=4
|
||||
url: https://github.com/requestly
|
||||
- login: acsone
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7601056?v=4
|
||||
url: https://github.com/acsone
|
||||
@@ -68,9 +62,6 @@ sponsors:
|
||||
- login: Doist
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2565372?v=4
|
||||
url: https://github.com/Doist
|
||||
- login: bholagabbar
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/11693595?v=4
|
||||
url: https://github.com/bholagabbar
|
||||
- - login: mainframeindustries
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/55092103?v=4
|
||||
url: https://github.com/mainframeindustries
|
||||
@@ -86,6 +77,9 @@ sponsors:
|
||||
- login: ChargeStorm
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/26000165?v=4
|
||||
url: https://github.com/ChargeStorm
|
||||
- login: ibrahimpelumi6142
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/113442282?v=4
|
||||
url: https://github.com/ibrahimpelumi6142
|
||||
- login: nilslindemann
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6892179?u=1dca6a22195d6cd1ab20737c0e19a4c55d639472&v=4
|
||||
url: https://github.com/nilslindemann
|
||||
@@ -116,124 +110,127 @@ sponsors:
|
||||
- login: Leay15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/32212558?u=c4aa9c1737e515959382a5515381757b1fd86c53&v=4
|
||||
url: https://github.com/Leay15
|
||||
- login: Karine-Bauch
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/90465103?u=7feb1018abb1a5631cfd9a91fea723d1ceb5f49b&v=4
|
||||
url: https://github.com/Karine-Bauch
|
||||
- login: jugeeem
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/116043716?u=ae590d79c38ac79c91b9c5caa6887d061e865a3d&v=4
|
||||
url: https://github.com/jugeeem
|
||||
- login: patsatsia
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/61111267?u=3271b85f7a37b479c8d0ae0a235182e83c166edf&v=4
|
||||
url: https://github.com/patsatsia
|
||||
- login: anthonycepeda
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72019805?u=60bdf46240cff8fca482ff0fc07d963fd5e1a27c&v=4
|
||||
url: https://github.com/anthonycepeda
|
||||
- login: patricioperezv
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/73832292?u=5f471f156e19ee7920e62ae0f4a47b95580e61cf&v=4
|
||||
url: https://github.com/patricioperezv
|
||||
- login: chickenandstats
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/79477966?u=ae2b894aa954070db1d7830dab99b49eba4e4567&v=4
|
||||
url: https://github.com/chickenandstats
|
||||
- login: Karine-Bauch
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/90465103?u=7feb1018abb1a5631cfd9a91fea723d1ceb5f49b&v=4
|
||||
url: https://github.com/Karine-Bauch
|
||||
- login: kaoru0310
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/80977929?u=1b61d10142b490e56af932ddf08a390fae8ee94f&v=4
|
||||
url: https://github.com/kaoru0310
|
||||
- login: jstanden
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/63288?u=c3658d57d2862c607a0e19c2101c3c51876e36ad&v=4
|
||||
url: https://github.com/jstanden
|
||||
- login: knallgelb
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2358812?u=c48cb6362b309d74cbf144bd6ad3aed3eb443e82&v=4
|
||||
url: https://github.com/knallgelb
|
||||
- login: dblackrun
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3528486?v=4
|
||||
url: https://github.com/dblackrun
|
||||
- login: zsinx6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3532625?u=ba75a5dc744d1116ccfeaaf30d41cb2fe81fe8dd&v=4
|
||||
url: https://github.com/zsinx6
|
||||
- login: kennywakeland
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3631417?u=7c8f743f1ae325dfadea7c62bbf1abd6a824fc55&v=4
|
||||
url: https://github.com/kennywakeland
|
||||
- login: aacayaco
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3634801?u=eaadda178c964178fcb64886f6c732172c8f8219&v=4
|
||||
url: https://github.com/aacayaco
|
||||
- login: anomaly
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3654837?v=4
|
||||
url: https://github.com/anomaly
|
||||
- login: mj0331
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3890353?u=1c627ac1a024515b4871de5c3ebbfaa1a57f65d4&v=4
|
||||
url: https://github.com/mj0331
|
||||
- login: gorhack
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4141690?u=ec119ebc4bdf00a7bc84657a71aa17834f4f27f3&v=4
|
||||
url: https://github.com/gorhack
|
||||
- login: Ryandaydev
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4292423?u=679ff84cb7b988c5795a5fa583857f574a055763&v=4
|
||||
url: https://github.com/Ryandaydev
|
||||
- login: jaredtrog
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4381365?v=4
|
||||
url: https://github.com/jaredtrog
|
||||
- login: chickenandstats
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/79477966?u=ae2b894aa954070db1d7830dab99b49eba4e4567&v=4
|
||||
url: https://github.com/chickenandstats
|
||||
- login: patricioperezv
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/73832292?u=5f471f156e19ee7920e62ae0f4a47b95580e61cf&v=4
|
||||
url: https://github.com/patricioperezv
|
||||
- login: anthonycepeda
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72019805?u=60bdf46240cff8fca482ff0fc07d963fd5e1a27c&v=4
|
||||
url: https://github.com/anthonycepeda
|
||||
- login: AalbatrossGuy
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/68378354?u=0bdeea9356d24f638244131f6d8d1e2d2f3601ca&v=4
|
||||
url: https://github.com/AalbatrossGuy
|
||||
- login: patsatsia
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/61111267?u=3271b85f7a37b479c8d0ae0a235182e83c166edf&v=4
|
||||
url: https://github.com/patsatsia
|
||||
- login: oliverxchen
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4471774?u=534191f25e32eeaadda22dfab4b0a428733d5489&v=4
|
||||
url: https://github.com/oliverxchen
|
||||
- login: paulcwatts
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/150269?u=1819e145d573b44f0ad74b87206d21cd60331d4e&v=4
|
||||
url: https://github.com/paulcwatts
|
||||
- login: robintw
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/296686?v=4
|
||||
url: https://github.com/robintw
|
||||
- login: pamelafox
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/297042?v=4
|
||||
url: https://github.com/pamelafox
|
||||
- login: wshayes
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/365303?u=07ca03c5ee811eb0920e633cc3c3db73dbec1aa5&v=4
|
||||
url: https://github.com/wshayes
|
||||
- login: koxudaxi
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/630670?u=507d8577b4b3670546b449c4c2ccbc5af40d72f7&v=4
|
||||
url: https://github.com/koxudaxi
|
||||
- login: falkben
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/653031?u=ad9838e089058c9e5a0bab94c0eec7cc181e0cd0&v=4
|
||||
url: https://github.com/falkben
|
||||
- login: mintuhouse
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/769950?u=ecfbd79a97d33177e0d093ddb088283cf7fe8444&v=4
|
||||
url: https://github.com/mintuhouse
|
||||
- login: jaredtrog
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4381365?v=4
|
||||
url: https://github.com/jaredtrog
|
||||
- login: Ryandaydev
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4292423?u=679ff84cb7b988c5795a5fa583857f574a055763&v=4
|
||||
url: https://github.com/Ryandaydev
|
||||
- login: gorhack
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4141690?u=ec119ebc4bdf00a7bc84657a71aa17834f4f27f3&v=4
|
||||
url: https://github.com/gorhack
|
||||
- login: mj0331
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3890353?u=1c627ac1a024515b4871de5c3ebbfaa1a57f65d4&v=4
|
||||
url: https://github.com/mj0331
|
||||
- login: anomaly
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3654837?v=4
|
||||
url: https://github.com/anomaly
|
||||
- login: aacayaco
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3634801?u=eaadda178c964178fcb64886f6c732172c8f8219&v=4
|
||||
url: https://github.com/aacayaco
|
||||
- login: kennywakeland
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3631417?u=7c8f743f1ae325dfadea7c62bbf1abd6a824fc55&v=4
|
||||
url: https://github.com/kennywakeland
|
||||
- login: zsinx6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3532625?u=ba75a5dc744d1116ccfeaaf30d41cb2fe81fe8dd&v=4
|
||||
url: https://github.com/zsinx6
|
||||
- login: dblackrun
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3528486?v=4
|
||||
url: https://github.com/dblackrun
|
||||
- login: knallgelb
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2358812?u=c48cb6362b309d74cbf144bd6ad3aed3eb443e82&v=4
|
||||
url: https://github.com/knallgelb
|
||||
- login: dodo5522
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1362607?u=9bf1e0e520cccc547c046610c468ce6115bbcf9f&v=4
|
||||
url: https://github.com/dodo5522
|
||||
- login: wdwinslow
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/11562137?u=371272f2c69e680e0559a7b0a57385e83a5dc728&v=4
|
||||
url: https://github.com/wdwinslow
|
||||
- login: jsoques
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/12414216?u=620921d94196546cc8b9eae2cc4cbc3f95bab42f&v=4
|
||||
url: https://github.com/jsoques
|
||||
- login: dannywade
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/13680237?u=418ee985bd41577b20fde81417fb2d901e875e8a&v=4
|
||||
url: https://github.com/dannywade
|
||||
- login: khadrawy
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/13686061?u=59f25ef42ecf04c22657aac4238ce0e2d3d30304&v=4
|
||||
url: https://github.com/khadrawy
|
||||
- login: mjohnsey
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16784016?u=38fad2e6b411244560b3af99c5f5a4751bc81865&v=4
|
||||
url: https://github.com/mjohnsey
|
||||
- login: ashi-agrawal
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/17105294?u=99c7a854035e5398d8e7b674f2d42baae6c957f8&v=4
|
||||
url: https://github.com/ashi-agrawal
|
||||
- login: mintuhouse
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/769950?u=ecfbd79a97d33177e0d093ddb088283cf7fe8444&v=4
|
||||
url: https://github.com/mintuhouse
|
||||
- login: falkben
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/653031?u=ad9838e089058c9e5a0bab94c0eec7cc181e0cd0&v=4
|
||||
url: https://github.com/falkben
|
||||
- login: koxudaxi
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/630670?u=507d8577b4b3670546b449c4c2ccbc5af40d72f7&v=4
|
||||
url: https://github.com/koxudaxi
|
||||
- login: wshayes
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/365303?u=07ca03c5ee811eb0920e633cc3c3db73dbec1aa5&v=4
|
||||
url: https://github.com/wshayes
|
||||
- login: pamelafox
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/297042?v=4
|
||||
url: https://github.com/pamelafox
|
||||
- login: robintw
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/296686?v=4
|
||||
url: https://github.com/robintw
|
||||
- login: jstanden
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/63288?u=c3658d57d2862c607a0e19c2101c3c51876e36ad&v=4
|
||||
url: https://github.com/jstanden
|
||||
- login: RaamEEIL
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/20320552?v=4
|
||||
url: https://github.com/RaamEEIL
|
||||
- login: ternaus
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5481618?u=513a26b02a39e7a28d587cd37c6cc877ea368e6e&v=4
|
||||
url: https://github.com/ternaus
|
||||
- login: eseglem
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5920492?u=208d419cf667b8ac594c82a8db01932c7e50d057&v=4
|
||||
url: https://github.com/eseglem
|
||||
- login: FernandoCelmer
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6262214?u=58ba6d5888fa7f355934e52db19f950e20b38162&v=4
|
||||
url: https://github.com/FernandoCelmer
|
||||
- login: Rehket
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7015688?u=3afb0ba200feebbc7f958950e92db34df2a3c172&v=4
|
||||
url: https://github.com/Rehket
|
||||
- login: ashi-agrawal
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/17105294?u=99c7a854035e5398d8e7b674f2d42baae6c957f8&v=4
|
||||
url: https://github.com/ashi-agrawal
|
||||
- login: mjohnsey
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16784016?u=38fad2e6b411244560b3af99c5f5a4751bc81865&v=4
|
||||
url: https://github.com/mjohnsey
|
||||
- login: khadrawy
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/13686061?u=59f25ef42ecf04c22657aac4238ce0e2d3d30304&v=4
|
||||
url: https://github.com/khadrawy
|
||||
- login: dannywade
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/13680237?u=418ee985bd41577b20fde81417fb2d901e875e8a&v=4
|
||||
url: https://github.com/dannywade
|
||||
- login: jsoques
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/12414216?u=620921d94196546cc8b9eae2cc4cbc3f95bab42f&v=4
|
||||
url: https://github.com/jsoques
|
||||
- login: wdwinslow
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/11562137?u=371272f2c69e680e0559a7b0a57385e83a5dc728&v=4
|
||||
url: https://github.com/wdwinslow
|
||||
- login: hiancdtrsnm
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7343177?v=4
|
||||
url: https://github.com/hiancdtrsnm
|
||||
- - login: manoelpqueiroz
|
||||
- login: Rehket
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7015688?u=3afb0ba200feebbc7f958950e92db34df2a3c172&v=4
|
||||
url: https://github.com/Rehket
|
||||
- login: FernandoCelmer
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6262214?u=58ba6d5888fa7f355934e52db19f950e20b38162&v=4
|
||||
url: https://github.com/FernandoCelmer
|
||||
- login: eseglem
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5920492?u=208d419cf667b8ac594c82a8db01932c7e50d057&v=4
|
||||
url: https://github.com/eseglem
|
||||
- login: ternaus
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5481618?u=513a26b02a39e7a28d587cd37c6cc877ea368e6e&v=4
|
||||
url: https://github.com/ternaus
|
||||
- - login: Artur-Galstyan
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/63471891?u=e8691f386037e51a737cc0ba866cd8c89e5cf109&v=4
|
||||
url: https://github.com/Artur-Galstyan
|
||||
- login: manoelpqueiroz
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/23669137?u=b12e84b28a84369ab5b30bd5a79e5788df5a0756&v=4
|
||||
url: https://github.com/manoelpqueiroz
|
||||
- - login: pawamoy
|
||||
@@ -254,9 +251,12 @@ sponsors:
|
||||
- login: hgalytoby
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/50397689?u=6cc9028f3db63f8f60ad21c17b1ce4b88c4e2e60&v=4
|
||||
url: https://github.com/hgalytoby
|
||||
- login: nisutec
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25281462?u=e562484c451fdfc59053163f64405f8eb262b8b0&v=4
|
||||
url: https://github.com/nisutec
|
||||
- login: johnl28
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/54412955?u=47dd06082d1c39caa90c752eb55566e4f3813957&v=4
|
||||
url: https://github.com/johnl28
|
||||
- login: danielunderwood
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4472301?v=4
|
||||
url: https://github.com/danielunderwood
|
||||
- login: hoenie-ams
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25708487?u=cda07434f0509ac728d9edf5e681117c0f6b818b&v=4
|
||||
url: https://github.com/hoenie-ams
|
||||
@@ -267,93 +267,87 @@ sponsors:
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/33275230?u=eb223cad27017bb1e936ee9b429b450d092d0236&v=4
|
||||
url: https://github.com/engineerjoe440
|
||||
- login: bnkc
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/34930566?u=db5e6f4f87836cad26c2aa90ce390ce49041c5a9&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/34930566?u=4771ac4e64066f0847d40e5b29910adabd9b2372&v=4
|
||||
url: https://github.com/bnkc
|
||||
- login: petercool
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37613029?u=75aa8c6729e6e8f85a300561c4dbeef9d65c8797&v=4
|
||||
url: https://github.com/petercool
|
||||
- login: johnl28
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/54412955?u=47dd06082d1c39caa90c752eb55566e4f3813957&v=4
|
||||
url: https://github.com/johnl28
|
||||
- login: PunRabbit
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/70463212?u=1a835cfbc99295a60c8282f6aa6199d1b42241a5&v=4
|
||||
url: https://github.com/PunRabbit
|
||||
- login: PelicanQ
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/77930606?v=4
|
||||
url: https://github.com/PelicanQ
|
||||
- login: WillHogan
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1661551?u=8a80356e3e7d5a417157aba7ea565dabc8678327&v=4
|
||||
url: https://github.com/WillHogan
|
||||
- login: PunRabbit
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/70463212?u=1a835cfbc99295a60c8282f6aa6199d1b42241a5&v=4
|
||||
url: https://github.com/PunRabbit
|
||||
- login: my3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1825270?v=4
|
||||
url: https://github.com/my3
|
||||
- login: danielunderwood
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4472301?v=4
|
||||
url: https://github.com/danielunderwood
|
||||
- login: ddanier
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/113563?u=ed1dc79de72f93bd78581f88ebc6952b62f472da&v=4
|
||||
url: https://github.com/ddanier
|
||||
- login: bryanculbertson
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/144028?u=defda4f90e93429221cc667500944abde60ebe4a&v=4
|
||||
url: https://github.com/bryanculbertson
|
||||
- login: slafs
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/210173?v=4
|
||||
url: https://github.com/slafs
|
||||
- login: ceb10n
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/235213?u=edcce471814a1eba9f0cdaa4cd0de18921a940a6&v=4
|
||||
url: https://github.com/ceb10n
|
||||
- login: tochikuji
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/851759?v=4
|
||||
url: https://github.com/tochikuji
|
||||
- login: WillHogan
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1661551?u=8a80356e3e7d5a417157aba7ea565dabc8678327&v=4
|
||||
url: https://github.com/WillHogan
|
||||
- login: miguelgr
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1484589?u=54556072b8136efa12ae3b6902032ea2a39ace4b&v=4
|
||||
url: https://github.com/miguelgr
|
||||
- login: xncbf
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9462045?u=a80a7bb349555b277645632ed66639ff43400614&v=4
|
||||
url: https://github.com/xncbf
|
||||
- login: DMantis
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9536869?u=652dd0d49717803c0cbcbf44f7740e53cf2d4892&v=4
|
||||
url: https://github.com/DMantis
|
||||
- login: hard-coders
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9651103?u=95db33927bbff1ed1c07efddeb97ac2ff33068ed&v=4
|
||||
url: https://github.com/hard-coders
|
||||
- login: mntolia
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10390224?v=4
|
||||
url: https://github.com/mntolia
|
||||
- login: Zuzah
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10934846?u=1ef43e075ddc87bd1178372bf4d95ee6175cae27&v=4
|
||||
url: https://github.com/Zuzah
|
||||
- login: TheR1D
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16740832?u=b0dfdbdb27b79729430c71c6128962f77b7b53f7&v=4
|
||||
url: https://github.com/TheR1D
|
||||
- login: tochikuji
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/851759?v=4
|
||||
url: https://github.com/tochikuji
|
||||
- login: ceb10n
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/235213?u=edcce471814a1eba9f0cdaa4cd0de18921a940a6&v=4
|
||||
url: https://github.com/ceb10n
|
||||
- login: slafs
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/210173?v=4
|
||||
url: https://github.com/slafs
|
||||
- login: bryanculbertson
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/144028?u=defda4f90e93429221cc667500944abde60ebe4a&v=4
|
||||
url: https://github.com/bryanculbertson
|
||||
- login: ddanier
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/113563?u=ed1dc79de72f93bd78581f88ebc6952b62f472da&v=4
|
||||
url: https://github.com/ddanier
|
||||
- login: nisutec
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25281462?u=e562484c451fdfc59053163f64405f8eb262b8b0&v=4
|
||||
url: https://github.com/nisutec
|
||||
- login: joshuatz
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/17817563?u=f1bf05b690d1fc164218f0b420cdd3acb7913e21&v=4
|
||||
url: https://github.com/joshuatz
|
||||
- login: rangulvers
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5235430?u=e254d4af4ace5a05fa58372ae677c7d26f0d5a53&v=4
|
||||
url: https://github.com/rangulvers
|
||||
- login: sdevkota
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5250987?u=4ed9a120c89805a8aefda1cbdc0cf6512e64d1b4&v=4
|
||||
url: https://github.com/sdevkota
|
||||
- login: Baghdady92
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5708590?v=4
|
||||
url: https://github.com/Baghdady92
|
||||
- login: KentShikama
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6329898?u=8b236810db9b96333230430837e1f021f9246da1&v=4
|
||||
url: https://github.com/KentShikama
|
||||
- login: katnoria
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7674948?u=09767eb13e07e09496c5fee4e5ce21d9eac34a56&v=4
|
||||
url: https://github.com/katnoria
|
||||
- login: harsh183
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7780198?v=4
|
||||
url: https://github.com/harsh183
|
||||
- login: TheR1D
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16740832?u=b0dfdbdb27b79729430c71c6128962f77b7b53f7&v=4
|
||||
url: https://github.com/TheR1D
|
||||
- login: Zuzah
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10934846?u=1ef43e075ddc87bd1178372bf4d95ee6175cae27&v=4
|
||||
url: https://github.com/Zuzah
|
||||
- login: mntolia
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10390224?v=4
|
||||
url: https://github.com/mntolia
|
||||
- login: hard-coders
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9651103?u=78d12d1acdf853c817700145e73de7fd9e5d068b&v=4
|
||||
url: https://github.com/hard-coders
|
||||
- login: DMantis
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9536869?u=652dd0d49717803c0cbcbf44f7740e53cf2d4892&v=4
|
||||
url: https://github.com/DMantis
|
||||
- login: xncbf
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9462045?u=a80a7bb349555b277645632ed66639ff43400614&v=4
|
||||
url: https://github.com/xncbf
|
||||
- login: moonape1226
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8532038?u=d9f8b855a429fff9397c3833c2ff83849ebf989d&v=4
|
||||
url: https://github.com/moonape1226
|
||||
- - login: andrecorumba
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37807517?u=9b9be3b41da9bda60957da9ef37b50dbf65baa61&v=4
|
||||
url: https://github.com/andrecorumba
|
||||
- login: KOZ39
|
||||
- login: harsh183
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7780198?v=4
|
||||
url: https://github.com/harsh183
|
||||
- login: katnoria
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7674948?u=09767eb13e07e09496c5fee4e5ce21d9eac34a56&v=4
|
||||
url: https://github.com/katnoria
|
||||
- login: KentShikama
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6329898?u=8b236810db9b96333230430837e1f021f9246da1&v=4
|
||||
url: https://github.com/KentShikama
|
||||
- login: Baghdady92
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5708590?v=4
|
||||
url: https://github.com/Baghdady92
|
||||
- login: sdevkota
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5250987?u=4ed9a120c89805a8aefda1cbdc0cf6512e64d1b4&v=4
|
||||
url: https://github.com/sdevkota
|
||||
- login: rangulvers
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5235430?u=e254d4af4ace5a05fa58372ae677c7d26f0d5a53&v=4
|
||||
url: https://github.com/rangulvers
|
||||
- - login: KOZ39
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/38822500?u=9dfc0a697df1c9628f08e20dc3fb17b1afc4e5a7&v=4
|
||||
url: https://github.com/KOZ39
|
||||
- login: rwxd
|
||||
@@ -365,27 +359,24 @@ sponsors:
|
||||
- login: Olegt0rr
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25399456?u=3e87b5239a2f4600975ba13be73054f8567c6060&v=4
|
||||
url: https://github.com/Olegt0rr
|
||||
- login: dinoz0rg
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/32940067?u=739cda1eb123a2dd5e1db45c361396f239e23f8b&v=4
|
||||
url: https://github.com/dinoz0rg
|
||||
- login: larsyngvelundin
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/34173819?u=74958599695bf83ac9f1addd935a51548a10c6b0&v=4
|
||||
url: https://github.com/larsyngvelundin
|
||||
- login: hippoley
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/135493401?u=1164ef48a645a7c12664fabc1638fbb7e1c459b0&v=4
|
||||
url: https://github.com/hippoley
|
||||
- login: 4anklee
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/144109238?u=a79c0d581b2a3d8f3897e7ef4c012640a6c1eb3a&v=4
|
||||
url: https://github.com/4anklee
|
||||
- login: andrecorumba
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37807517?u=9b9be3b41da9bda60957da9ef37b50dbf65baa61&v=4
|
||||
url: https://github.com/andrecorumba
|
||||
- login: CoderDeltaLAN
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/152043745?u=4ff541efffb7d134e60c5fcf2dd1e343f90bb782&v=4
|
||||
url: https://github.com/CoderDeltaLAN
|
||||
- login: onestn
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62360849?u=746dd21c34e7e06eefb11b03e8bb01aaae3c2a4f&v=4
|
||||
url: https://github.com/onestn
|
||||
- login: hippoley
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/135493401?u=1164ef48a645a7c12664fabc1638fbb7e1c459b0&v=4
|
||||
url: https://github.com/hippoley
|
||||
- login: nayasinghania
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/74111380?u=752e99a5e139389fdc0a0677122adc08438eb076&v=4
|
||||
url: https://github.com/nayasinghania
|
||||
- login: onestn
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62360849?u=746dd21c34e7e06eefb11b03e8bb01aaae3c2a4f&v=4
|
||||
url: https://github.com/onestn
|
||||
- login: Toothwitch
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1710406?u=5eebb23b46cd26e48643b9e5179536cad491c17a&v=4
|
||||
url: https://github.com/Toothwitch
|
||||
|
||||
@@ -1,495 +1,495 @@
|
||||
- name: full-stack-fastapi-template
|
||||
html_url: https://github.com/fastapi/full-stack-fastapi-template
|
||||
stars: 39475
|
||||
stars: 40334
|
||||
owner_login: fastapi
|
||||
owner_html_url: https://github.com/fastapi
|
||||
- name: Hello-Python
|
||||
html_url: https://github.com/mouredev/Hello-Python
|
||||
stars: 33090
|
||||
stars: 33628
|
||||
owner_login: mouredev
|
||||
owner_html_url: https://github.com/mouredev
|
||||
- name: serve
|
||||
html_url: https://github.com/jina-ai/serve
|
||||
stars: 21798
|
||||
stars: 21817
|
||||
owner_login: jina-ai
|
||||
owner_html_url: https://github.com/jina-ai
|
||||
- name: HivisionIDPhotos
|
||||
html_url: https://github.com/Zeyi-Lin/HivisionIDPhotos
|
||||
stars: 20258
|
||||
stars: 20409
|
||||
owner_login: Zeyi-Lin
|
||||
owner_html_url: https://github.com/Zeyi-Lin
|
||||
- name: sqlmodel
|
||||
html_url: https://github.com/fastapi/sqlmodel
|
||||
stars: 17212
|
||||
stars: 17415
|
||||
owner_login: fastapi
|
||||
owner_html_url: https://github.com/fastapi
|
||||
- name: Douyin_TikTok_Download_API
|
||||
html_url: https://github.com/Evil0ctal/Douyin_TikTok_Download_API
|
||||
stars: 15145
|
||||
owner_login: Evil0ctal
|
||||
owner_html_url: https://github.com/Evil0ctal
|
||||
- name: fastapi-best-practices
|
||||
html_url: https://github.com/zhanymkanov/fastapi-best-practices
|
||||
stars: 14644
|
||||
stars: 15776
|
||||
owner_login: zhanymkanov
|
||||
owner_html_url: https://github.com/zhanymkanov
|
||||
- name: Douyin_TikTok_Download_API
|
||||
html_url: https://github.com/Evil0ctal/Douyin_TikTok_Download_API
|
||||
stars: 15588
|
||||
owner_login: Evil0ctal
|
||||
owner_html_url: https://github.com/Evil0ctal
|
||||
- name: machine-learning-zoomcamp
|
||||
html_url: https://github.com/DataTalksClub/machine-learning-zoomcamp
|
||||
stars: 12320
|
||||
stars: 12447
|
||||
owner_login: DataTalksClub
|
||||
owner_html_url: https://github.com/DataTalksClub
|
||||
- name: fastapi_mcp
|
||||
html_url: https://github.com/tadata-org/fastapi_mcp
|
||||
stars: 11174
|
||||
owner_login: tadata-org
|
||||
owner_html_url: https://github.com/tadata-org
|
||||
- name: SurfSense
|
||||
html_url: https://github.com/MODSetter/SurfSense
|
||||
stars: 10858
|
||||
stars: 12128
|
||||
owner_login: MODSetter
|
||||
owner_html_url: https://github.com/MODSetter
|
||||
- name: fastapi_mcp
|
||||
html_url: https://github.com/tadata-org/fastapi_mcp
|
||||
stars: 11326
|
||||
owner_login: tadata-org
|
||||
owner_html_url: https://github.com/tadata-org
|
||||
- name: awesome-fastapi
|
||||
html_url: https://github.com/mjhea0/awesome-fastapi
|
||||
stars: 10758
|
||||
stars: 10901
|
||||
owner_login: mjhea0
|
||||
owner_html_url: https://github.com/mjhea0
|
||||
- name: XHS-Downloader
|
||||
html_url: https://github.com/JoeanAmier/XHS-Downloader
|
||||
stars: 9313
|
||||
stars: 9584
|
||||
owner_login: JoeanAmier
|
||||
owner_html_url: https://github.com/JoeanAmier
|
||||
- name: FastUI
|
||||
html_url: https://github.com/pydantic/FastUI
|
||||
stars: 8915
|
||||
owner_login: pydantic
|
||||
owner_html_url: https://github.com/pydantic
|
||||
- name: polar
|
||||
html_url: https://github.com/polarsource/polar
|
||||
stars: 8339
|
||||
stars: 8951
|
||||
owner_login: polarsource
|
||||
owner_html_url: https://github.com/polarsource
|
||||
- name: FastUI
|
||||
html_url: https://github.com/pydantic/FastUI
|
||||
stars: 8934
|
||||
owner_login: pydantic
|
||||
owner_html_url: https://github.com/pydantic
|
||||
- name: FileCodeBox
|
||||
html_url: https://github.com/vastsa/FileCodeBox
|
||||
stars: 7721
|
||||
stars: 7934
|
||||
owner_login: vastsa
|
||||
owner_html_url: https://github.com/vastsa
|
||||
- name: nonebot2
|
||||
html_url: https://github.com/nonebot/nonebot2
|
||||
stars: 7170
|
||||
stars: 7248
|
||||
owner_login: nonebot
|
||||
owner_html_url: https://github.com/nonebot
|
||||
- name: hatchet
|
||||
html_url: https://github.com/hatchet-dev/hatchet
|
||||
stars: 6253
|
||||
stars: 6392
|
||||
owner_login: hatchet-dev
|
||||
owner_html_url: https://github.com/hatchet-dev
|
||||
- name: fastapi-users
|
||||
html_url: https://github.com/fastapi-users/fastapi-users
|
||||
stars: 5849
|
||||
stars: 5899
|
||||
owner_login: fastapi-users
|
||||
owner_html_url: https://github.com/fastapi-users
|
||||
- name: serge
|
||||
html_url: https://github.com/serge-chat/serge
|
||||
stars: 5756
|
||||
stars: 5754
|
||||
owner_login: serge-chat
|
||||
owner_html_url: https://github.com/serge-chat
|
||||
- name: strawberry
|
||||
html_url: https://github.com/strawberry-graphql/strawberry
|
||||
stars: 4569
|
||||
stars: 4577
|
||||
owner_login: strawberry-graphql
|
||||
owner_html_url: https://github.com/strawberry-graphql
|
||||
- name: chatgpt-web-share
|
||||
html_url: https://github.com/chatpire/chatgpt-web-share
|
||||
stars: 4294
|
||||
owner_login: chatpire
|
||||
owner_html_url: https://github.com/chatpire
|
||||
- name: poem
|
||||
html_url: https://github.com/poem-web/poem
|
||||
stars: 4276
|
||||
stars: 4303
|
||||
owner_login: poem-web
|
||||
owner_html_url: https://github.com/poem-web
|
||||
- name: chatgpt-web-share
|
||||
html_url: https://github.com/chatpire/chatgpt-web-share
|
||||
stars: 4287
|
||||
owner_login: chatpire
|
||||
owner_html_url: https://github.com/chatpire
|
||||
- name: dynaconf
|
||||
html_url: https://github.com/dynaconf/dynaconf
|
||||
stars: 4202
|
||||
stars: 4221
|
||||
owner_login: dynaconf
|
||||
owner_html_url: https://github.com/dynaconf
|
||||
- name: atrilabs-engine
|
||||
html_url: https://github.com/Atri-Labs/atrilabs-engine
|
||||
stars: 4093
|
||||
owner_login: Atri-Labs
|
||||
owner_html_url: https://github.com/Atri-Labs
|
||||
- name: Kokoro-FastAPI
|
||||
html_url: https://github.com/remsky/Kokoro-FastAPI
|
||||
stars: 4019
|
||||
stars: 4181
|
||||
owner_login: remsky
|
||||
owner_html_url: https://github.com/remsky
|
||||
- name: atrilabs-engine
|
||||
html_url: https://github.com/Atri-Labs/atrilabs-engine
|
||||
stars: 4090
|
||||
owner_login: Atri-Labs
|
||||
owner_html_url: https://github.com/Atri-Labs
|
||||
- name: devpush
|
||||
html_url: https://github.com/hunvreus/devpush
|
||||
stars: 4037
|
||||
owner_login: hunvreus
|
||||
owner_html_url: https://github.com/hunvreus
|
||||
- name: logfire
|
||||
html_url: https://github.com/pydantic/logfire
|
||||
stars: 3805
|
||||
stars: 3896
|
||||
owner_login: pydantic
|
||||
owner_html_url: https://github.com/pydantic
|
||||
- name: LitServe
|
||||
html_url: https://github.com/Lightning-AI/LitServe
|
||||
stars: 3719
|
||||
stars: 3756
|
||||
owner_login: Lightning-AI
|
||||
owner_html_url: https://github.com/Lightning-AI
|
||||
- name: fastapi-admin
|
||||
html_url: https://github.com/fastapi-admin/fastapi-admin
|
||||
stars: 3632
|
||||
owner_login: fastapi-admin
|
||||
owner_html_url: https://github.com/fastapi-admin
|
||||
- name: datamodel-code-generator
|
||||
html_url: https://github.com/koxudaxi/datamodel-code-generator
|
||||
stars: 3609
|
||||
owner_login: koxudaxi
|
||||
owner_html_url: https://github.com/koxudaxi
|
||||
- name: huma
|
||||
html_url: https://github.com/danielgtaylor/huma
|
||||
stars: 3603
|
||||
stars: 3702
|
||||
owner_login: danielgtaylor
|
||||
owner_html_url: https://github.com/danielgtaylor
|
||||
- name: Yuxi-Know
|
||||
html_url: https://github.com/xerrors/Yuxi-Know
|
||||
stars: 3680
|
||||
owner_login: xerrors
|
||||
owner_html_url: https://github.com/xerrors
|
||||
- name: datamodel-code-generator
|
||||
html_url: https://github.com/koxudaxi/datamodel-code-generator
|
||||
stars: 3675
|
||||
owner_login: koxudaxi
|
||||
owner_html_url: https://github.com/koxudaxi
|
||||
- name: fastapi-admin
|
||||
html_url: https://github.com/fastapi-admin/fastapi-admin
|
||||
stars: 3659
|
||||
owner_login: fastapi-admin
|
||||
owner_html_url: https://github.com/fastapi-admin
|
||||
- name: farfalle
|
||||
html_url: https://github.com/rashadphz/farfalle
|
||||
stars: 3490
|
||||
stars: 3497
|
||||
owner_login: rashadphz
|
||||
owner_html_url: https://github.com/rashadphz
|
||||
- name: tracecat
|
||||
html_url: https://github.com/TracecatHQ/tracecat
|
||||
stars: 3379
|
||||
stars: 3421
|
||||
owner_login: TracecatHQ
|
||||
owner_html_url: https://github.com/TracecatHQ
|
||||
- name: opyrator
|
||||
html_url: https://github.com/ml-tooling/opyrator
|
||||
stars: 3135
|
||||
stars: 3136
|
||||
owner_login: ml-tooling
|
||||
owner_html_url: https://github.com/ml-tooling
|
||||
- name: docarray
|
||||
html_url: https://github.com/docarray/docarray
|
||||
stars: 3114
|
||||
stars: 3111
|
||||
owner_login: docarray
|
||||
owner_html_url: https://github.com/docarray
|
||||
- name: devpush
|
||||
html_url: https://github.com/hunvreus/devpush
|
||||
stars: 3097
|
||||
owner_login: hunvreus
|
||||
owner_html_url: https://github.com/hunvreus
|
||||
- name: fastapi-realworld-example-app
|
||||
html_url: https://github.com/nsidnev/fastapi-realworld-example-app
|
||||
stars: 3050
|
||||
stars: 3051
|
||||
owner_login: nsidnev
|
||||
owner_html_url: https://github.com/nsidnev
|
||||
- name: uvicorn-gunicorn-fastapi-docker
|
||||
html_url: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker
|
||||
stars: 2911
|
||||
owner_login: tiangolo
|
||||
owner_html_url: https://github.com/tiangolo
|
||||
- name: mcp-context-forge
|
||||
html_url: https://github.com/IBM/mcp-context-forge
|
||||
stars: 2899
|
||||
stars: 3034
|
||||
owner_login: IBM
|
||||
owner_html_url: https://github.com/IBM
|
||||
- name: best-of-web-python
|
||||
html_url: https://github.com/ml-tooling/best-of-web-python
|
||||
stars: 2648
|
||||
owner_login: ml-tooling
|
||||
owner_html_url: https://github.com/ml-tooling
|
||||
- name: uvicorn-gunicorn-fastapi-docker
|
||||
html_url: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker
|
||||
stars: 2904
|
||||
owner_login: tiangolo
|
||||
owner_html_url: https://github.com/tiangolo
|
||||
- name: FastAPI-template
|
||||
html_url: https://github.com/s3rius/FastAPI-template
|
||||
stars: 2637
|
||||
stars: 2680
|
||||
owner_login: s3rius
|
||||
owner_html_url: https://github.com/s3rius
|
||||
- name: best-of-web-python
|
||||
html_url: https://github.com/ml-tooling/best-of-web-python
|
||||
stars: 2662
|
||||
owner_login: ml-tooling
|
||||
owner_html_url: https://github.com/ml-tooling
|
||||
- name: YC-Killer
|
||||
html_url: https://github.com/sahibzada-allahyar/YC-Killer
|
||||
stars: 2599
|
||||
stars: 2614
|
||||
owner_login: sahibzada-allahyar
|
||||
owner_html_url: https://github.com/sahibzada-allahyar
|
||||
- name: fastapi-react
|
||||
html_url: https://github.com/Buuntu/fastapi-react
|
||||
stars: 2569
|
||||
owner_login: Buuntu
|
||||
owner_html_url: https://github.com/Buuntu
|
||||
- name: Yuxi-Know
|
||||
html_url: https://github.com/xerrors/Yuxi-Know
|
||||
stars: 2563
|
||||
owner_login: xerrors
|
||||
owner_html_url: https://github.com/xerrors
|
||||
- name: sqladmin
|
||||
html_url: https://github.com/aminalaee/sqladmin
|
||||
stars: 2558
|
||||
stars: 2587
|
||||
owner_login: aminalaee
|
||||
owner_html_url: https://github.com/aminalaee
|
||||
- name: fastapi-react
|
||||
html_url: https://github.com/Buuntu/fastapi-react
|
||||
stars: 2566
|
||||
owner_login: Buuntu
|
||||
owner_html_url: https://github.com/Buuntu
|
||||
- name: RasaGPT
|
||||
html_url: https://github.com/paulpierre/RasaGPT
|
||||
stars: 2451
|
||||
stars: 2456
|
||||
owner_login: paulpierre
|
||||
owner_html_url: https://github.com/paulpierre
|
||||
- name: supabase-py
|
||||
html_url: https://github.com/supabase/supabase-py
|
||||
stars: 2344
|
||||
stars: 2394
|
||||
owner_login: supabase
|
||||
owner_html_url: https://github.com/supabase
|
||||
- name: nextpy
|
||||
html_url: https://github.com/dot-agent/nextpy
|
||||
stars: 2335
|
||||
stars: 2338
|
||||
owner_login: dot-agent
|
||||
owner_html_url: https://github.com/dot-agent
|
||||
- name: fastapi-utils
|
||||
html_url: https://github.com/fastapiutils/fastapi-utils
|
||||
stars: 2291
|
||||
stars: 2289
|
||||
owner_login: fastapiutils
|
||||
owner_html_url: https://github.com/fastapiutils
|
||||
- name: 30-Days-of-Python
|
||||
html_url: https://github.com/codingforentrepreneurs/30-Days-of-Python
|
||||
stars: 2220
|
||||
owner_login: codingforentrepreneurs
|
||||
owner_html_url: https://github.com/codingforentrepreneurs
|
||||
- name: langserve
|
||||
html_url: https://github.com/langchain-ai/langserve
|
||||
stars: 2215
|
||||
stars: 2234
|
||||
owner_login: langchain-ai
|
||||
owner_html_url: https://github.com/langchain-ai
|
||||
- name: 30-Days-of-Python
|
||||
html_url: https://github.com/codingforentrepreneurs/30-Days-of-Python
|
||||
stars: 2232
|
||||
owner_login: codingforentrepreneurs
|
||||
owner_html_url: https://github.com/codingforentrepreneurs
|
||||
- name: solara
|
||||
html_url: https://github.com/widgetti/solara
|
||||
stars: 2122
|
||||
stars: 2141
|
||||
owner_login: widgetti
|
||||
owner_html_url: https://github.com/widgetti
|
||||
- name: mangum
|
||||
html_url: https://github.com/Kludex/mangum
|
||||
stars: 2029
|
||||
stars: 2046
|
||||
owner_login: Kludex
|
||||
owner_html_url: https://github.com/Kludex
|
||||
- name: fastapi_best_architecture
|
||||
html_url: https://github.com/fastapi-practices/fastapi_best_architecture
|
||||
stars: 1963
|
||||
owner_login: fastapi-practices
|
||||
owner_html_url: https://github.com/fastapi-practices
|
||||
- name: NoteDiscovery
|
||||
html_url: https://github.com/gamosoft/NoteDiscovery
|
||||
stars: 1943
|
||||
owner_login: gamosoft
|
||||
owner_html_url: https://github.com/gamosoft
|
||||
- name: agentkit
|
||||
html_url: https://github.com/BCG-X-Official/agentkit
|
||||
stars: 1912
|
||||
stars: 1936
|
||||
owner_login: BCG-X-Official
|
||||
owner_html_url: https://github.com/BCG-X-Official
|
||||
- name: vue-fastapi-admin
|
||||
html_url: https://github.com/mizhexiaoxiao/vue-fastapi-admin
|
||||
stars: 1909
|
||||
owner_login: mizhexiaoxiao
|
||||
owner_html_url: https://github.com/mizhexiaoxiao
|
||||
- name: manage-fastapi
|
||||
html_url: https://github.com/ycd/manage-fastapi
|
||||
stars: 1885
|
||||
stars: 1887
|
||||
owner_login: ycd
|
||||
owner_html_url: https://github.com/ycd
|
||||
- name: openapi-python-client
|
||||
html_url: https://github.com/openapi-generators/openapi-python-client
|
||||
stars: 1862
|
||||
stars: 1879
|
||||
owner_login: openapi-generators
|
||||
owner_html_url: https://github.com/openapi-generators
|
||||
- name: piccolo
|
||||
html_url: https://github.com/piccolo-orm/piccolo
|
||||
stars: 1836
|
||||
owner_login: piccolo-orm
|
||||
owner_html_url: https://github.com/piccolo-orm
|
||||
- name: vue-fastapi-admin
|
||||
html_url: https://github.com/mizhexiaoxiao/vue-fastapi-admin
|
||||
stars: 1831
|
||||
owner_login: mizhexiaoxiao
|
||||
owner_html_url: https://github.com/mizhexiaoxiao
|
||||
- name: python-week-2022
|
||||
html_url: https://github.com/rochacbruno/python-week-2022
|
||||
stars: 1817
|
||||
owner_login: rochacbruno
|
||||
owner_html_url: https://github.com/rochacbruno
|
||||
- name: slowapi
|
||||
html_url: https://github.com/laurentS/slowapi
|
||||
stars: 1798
|
||||
stars: 1845
|
||||
owner_login: laurentS
|
||||
owner_html_url: https://github.com/laurentS
|
||||
- name: piccolo
|
||||
html_url: https://github.com/piccolo-orm/piccolo
|
||||
stars: 1843
|
||||
owner_login: piccolo-orm
|
||||
owner_html_url: https://github.com/piccolo-orm
|
||||
- name: python-week-2022
|
||||
html_url: https://github.com/rochacbruno/python-week-2022
|
||||
stars: 1813
|
||||
owner_login: rochacbruno
|
||||
owner_html_url: https://github.com/rochacbruno
|
||||
- name: fastapi-cache
|
||||
html_url: https://github.com/long2ice/fastapi-cache
|
||||
stars: 1789
|
||||
stars: 1805
|
||||
owner_login: long2ice
|
||||
owner_html_url: https://github.com/long2ice
|
||||
- name: ormar
|
||||
html_url: https://github.com/collerek/ormar
|
||||
stars: 1783
|
||||
stars: 1785
|
||||
owner_login: collerek
|
||||
owner_html_url: https://github.com/collerek
|
||||
- name: termpair
|
||||
html_url: https://github.com/cs01/termpair
|
||||
stars: 1716
|
||||
owner_login: cs01
|
||||
owner_html_url: https://github.com/cs01
|
||||
- name: FastAPI-boilerplate
|
||||
html_url: https://github.com/benavlabs/FastAPI-boilerplate
|
||||
stars: 1660
|
||||
owner_login: benavlabs
|
||||
owner_html_url: https://github.com/benavlabs
|
||||
- name: fastapi-langgraph-agent-production-ready-template
|
||||
html_url: https://github.com/wassim249/fastapi-langgraph-agent-production-ready-template
|
||||
stars: 1638
|
||||
stars: 1780
|
||||
owner_login: wassim249
|
||||
owner_html_url: https://github.com/wassim249
|
||||
- name: langchain-serve
|
||||
html_url: https://github.com/jina-ai/langchain-serve
|
||||
stars: 1635
|
||||
owner_login: jina-ai
|
||||
owner_html_url: https://github.com/jina-ai
|
||||
- name: awesome-fastapi-projects
|
||||
html_url: https://github.com/Kludex/awesome-fastapi-projects
|
||||
stars: 1589
|
||||
owner_login: Kludex
|
||||
owner_html_url: https://github.com/Kludex
|
||||
- name: fastapi-pagination
|
||||
html_url: https://github.com/uriyyo/fastapi-pagination
|
||||
stars: 1585
|
||||
owner_login: uriyyo
|
||||
owner_html_url: https://github.com/uriyyo
|
||||
- name: coronavirus-tracker-api
|
||||
html_url: https://github.com/ExpDev07/coronavirus-tracker-api
|
||||
stars: 1574
|
||||
owner_login: ExpDev07
|
||||
owner_html_url: https://github.com/ExpDev07
|
||||
- name: FastAPI-boilerplate
|
||||
html_url: https://github.com/benavlabs/FastAPI-boilerplate
|
||||
stars: 1734
|
||||
owner_login: benavlabs
|
||||
owner_html_url: https://github.com/benavlabs
|
||||
- name: termpair
|
||||
html_url: https://github.com/cs01/termpair
|
||||
stars: 1724
|
||||
owner_login: cs01
|
||||
owner_html_url: https://github.com/cs01
|
||||
- name: fastapi-crudrouter
|
||||
html_url: https://github.com/awtkns/fastapi-crudrouter
|
||||
stars: 1559
|
||||
stars: 1671
|
||||
owner_login: awtkns
|
||||
owner_html_url: https://github.com/awtkns
|
||||
- name: langchain-serve
|
||||
html_url: https://github.com/jina-ai/langchain-serve
|
||||
stars: 1633
|
||||
owner_login: jina-ai
|
||||
owner_html_url: https://github.com/jina-ai
|
||||
- name: fastapi-pagination
|
||||
html_url: https://github.com/uriyyo/fastapi-pagination
|
||||
stars: 1588
|
||||
owner_login: uriyyo
|
||||
owner_html_url: https://github.com/uriyyo
|
||||
- name: awesome-fastapi-projects
|
||||
html_url: https://github.com/Kludex/awesome-fastapi-projects
|
||||
stars: 1583
|
||||
owner_login: Kludex
|
||||
owner_html_url: https://github.com/Kludex
|
||||
- name: coronavirus-tracker-api
|
||||
html_url: https://github.com/ExpDev07/coronavirus-tracker-api
|
||||
stars: 1571
|
||||
owner_login: ExpDev07
|
||||
owner_html_url: https://github.com/ExpDev07
|
||||
- name: bracket
|
||||
html_url: https://github.com/evroon/bracket
|
||||
stars: 1489
|
||||
stars: 1549
|
||||
owner_login: evroon
|
||||
owner_html_url: https://github.com/evroon
|
||||
- name: fastapi-amis-admin
|
||||
html_url: https://github.com/amisadmin/fastapi-amis-admin
|
||||
stars: 1475
|
||||
stars: 1491
|
||||
owner_login: amisadmin
|
||||
owner_html_url: https://github.com/amisadmin
|
||||
- name: fastapi-boilerplate
|
||||
html_url: https://github.com/teamhide/fastapi-boilerplate
|
||||
stars: 1436
|
||||
stars: 1452
|
||||
owner_login: teamhide
|
||||
owner_html_url: https://github.com/teamhide
|
||||
- name: awesome-python-resources
|
||||
html_url: https://github.com/DjangoEx/awesome-python-resources
|
||||
stars: 1426
|
||||
owner_login: DjangoEx
|
||||
owner_html_url: https://github.com/DjangoEx
|
||||
- name: fastcrud
|
||||
html_url: https://github.com/benavlabs/fastcrud
|
||||
stars: 1414
|
||||
stars: 1452
|
||||
owner_login: benavlabs
|
||||
owner_html_url: https://github.com/benavlabs
|
||||
- name: awesome-python-resources
|
||||
html_url: https://github.com/DjangoEx/awesome-python-resources
|
||||
stars: 1430
|
||||
owner_login: DjangoEx
|
||||
owner_html_url: https://github.com/DjangoEx
|
||||
- name: prometheus-fastapi-instrumentator
|
||||
html_url: https://github.com/trallnag/prometheus-fastapi-instrumentator
|
||||
stars: 1388
|
||||
stars: 1399
|
||||
owner_login: trallnag
|
||||
owner_html_url: https://github.com/trallnag
|
||||
- name: fastapi_best_architecture
|
||||
html_url: https://github.com/fastapi-practices/fastapi_best_architecture
|
||||
stars: 1378
|
||||
owner_login: fastapi-practices
|
||||
owner_html_url: https://github.com/fastapi-practices
|
||||
- name: fastapi-code-generator
|
||||
html_url: https://github.com/koxudaxi/fastapi-code-generator
|
||||
stars: 1375
|
||||
stars: 1371
|
||||
owner_login: koxudaxi
|
||||
owner_html_url: https://github.com/koxudaxi
|
||||
- name: fastapi-tutorial
|
||||
html_url: https://github.com/liaogx/fastapi-tutorial
|
||||
stars: 1346
|
||||
owner_login: liaogx
|
||||
owner_html_url: https://github.com/liaogx
|
||||
- name: budgetml
|
||||
html_url: https://github.com/ebhy/budgetml
|
||||
stars: 1345
|
||||
owner_login: ebhy
|
||||
owner_html_url: https://github.com/ebhy
|
||||
- name: fastapi-tutorial
|
||||
html_url: https://github.com/liaogx/fastapi-tutorial
|
||||
stars: 1327
|
||||
owner_login: liaogx
|
||||
owner_html_url: https://github.com/liaogx
|
||||
- name: fastapi-alembic-sqlmodel-async
|
||||
html_url: https://github.com/jonra1993/fastapi-alembic-sqlmodel-async
|
||||
stars: 1259
|
||||
owner_login: jonra1993
|
||||
owner_html_url: https://github.com/jonra1993
|
||||
- name: fastapi-scaff
|
||||
html_url: https://github.com/atpuxiner/fastapi-scaff
|
||||
stars: 1255
|
||||
stars: 1331
|
||||
owner_login: atpuxiner
|
||||
owner_html_url: https://github.com/atpuxiner
|
||||
- name: bedrock-chat
|
||||
html_url: https://github.com/aws-samples/bedrock-chat
|
||||
stars: 1254
|
||||
owner_login: aws-samples
|
||||
owner_html_url: https://github.com/aws-samples
|
||||
- name: bolt-python
|
||||
html_url: https://github.com/slackapi/bolt-python
|
||||
stars: 1253
|
||||
stars: 1266
|
||||
owner_login: slackapi
|
||||
owner_html_url: https://github.com/slackapi
|
||||
- name: bedrock-chat
|
||||
html_url: https://github.com/aws-samples/bedrock-chat
|
||||
stars: 1266
|
||||
owner_login: aws-samples
|
||||
owner_html_url: https://github.com/aws-samples
|
||||
- name: fastapi-alembic-sqlmodel-async
|
||||
html_url: https://github.com/jonra1993/fastapi-alembic-sqlmodel-async
|
||||
stars: 1260
|
||||
owner_login: jonra1993
|
||||
owner_html_url: https://github.com/jonra1993
|
||||
- name: fastapi_production_template
|
||||
html_url: https://github.com/zhanymkanov/fastapi_production_template
|
||||
stars: 1217
|
||||
stars: 1222
|
||||
owner_login: zhanymkanov
|
||||
owner_html_url: https://github.com/zhanymkanov
|
||||
- name: langchain-extract
|
||||
html_url: https://github.com/langchain-ai/langchain-extract
|
||||
stars: 1176
|
||||
stars: 1179
|
||||
owner_login: langchain-ai
|
||||
owner_html_url: https://github.com/langchain-ai
|
||||
- name: restish
|
||||
html_url: https://github.com/rest-sh/restish
|
||||
stars: 1140
|
||||
stars: 1152
|
||||
owner_login: rest-sh
|
||||
owner_html_url: https://github.com/rest-sh
|
||||
- name: odmantic
|
||||
html_url: https://github.com/art049/odmantic
|
||||
stars: 1138
|
||||
stars: 1143
|
||||
owner_login: art049
|
||||
owner_html_url: https://github.com/art049
|
||||
- name: authx
|
||||
html_url: https://github.com/yezz123/authx
|
||||
stars: 1119
|
||||
stars: 1128
|
||||
owner_login: yezz123
|
||||
owner_html_url: https://github.com/yezz123
|
||||
- name: NoteDiscovery
|
||||
html_url: https://github.com/gamosoft/NoteDiscovery
|
||||
stars: 1107
|
||||
owner_login: gamosoft
|
||||
owner_html_url: https://github.com/gamosoft
|
||||
- name: flock
|
||||
html_url: https://github.com/Onelevenvy/flock
|
||||
stars: 1055
|
||||
owner_login: Onelevenvy
|
||||
owner_html_url: https://github.com/Onelevenvy
|
||||
- name: fastapi-observability
|
||||
html_url: https://github.com/blueswen/fastapi-observability
|
||||
stars: 1038
|
||||
owner_login: blueswen
|
||||
owner_html_url: https://github.com/blueswen
|
||||
- name: SAG
|
||||
html_url: https://github.com/Zleap-AI/SAG
|
||||
stars: 1104
|
||||
owner_login: Zleap-AI
|
||||
owner_html_url: https://github.com/Zleap-AI
|
||||
- name: aktools
|
||||
html_url: https://github.com/akfamily/aktools
|
||||
stars: 1027
|
||||
stars: 1072
|
||||
owner_login: akfamily
|
||||
owner_html_url: https://github.com/akfamily
|
||||
- name: RuoYi-Vue3-FastAPI
|
||||
html_url: https://github.com/insistence/RuoYi-Vue3-FastAPI
|
||||
stars: 1016
|
||||
stars: 1063
|
||||
owner_login: insistence
|
||||
owner_html_url: https://github.com/insistence
|
||||
- name: autollm
|
||||
html_url: https://github.com/viddexa/autollm
|
||||
stars: 1002
|
||||
owner_login: viddexa
|
||||
owner_html_url: https://github.com/viddexa
|
||||
- name: titiler
|
||||
html_url: https://github.com/developmentseed/titiler
|
||||
stars: 999
|
||||
owner_login: developmentseed
|
||||
owner_html_url: https://github.com/developmentseed
|
||||
- name: lanarky
|
||||
html_url: https://github.com/ajndkr/lanarky
|
||||
stars: 994
|
||||
owner_login: ajndkr
|
||||
owner_html_url: https://github.com/ajndkr
|
||||
- name: every-pdf
|
||||
html_url: https://github.com/DDULDDUCK/every-pdf
|
||||
stars: 985
|
||||
owner_login: DDULDDUCK
|
||||
owner_html_url: https://github.com/DDULDDUCK
|
||||
- name: flock
|
||||
html_url: https://github.com/Onelevenvy/flock
|
||||
stars: 1059
|
||||
owner_login: Onelevenvy
|
||||
owner_html_url: https://github.com/Onelevenvy
|
||||
- name: fastapi-observability
|
||||
html_url: https://github.com/blueswen/fastapi-observability
|
||||
stars: 1046
|
||||
owner_login: blueswen
|
||||
owner_html_url: https://github.com/blueswen
|
||||
- name: enterprise-deep-research
|
||||
html_url: https://github.com/SalesforceAIResearch/enterprise-deep-research
|
||||
stars: 973
|
||||
stars: 1019
|
||||
owner_login: SalesforceAIResearch
|
||||
owner_html_url: https://github.com/SalesforceAIResearch
|
||||
- name: fastapi-mail
|
||||
html_url: https://github.com/sabuhish/fastapi-mail
|
||||
stars: 964
|
||||
owner_login: sabuhish
|
||||
owner_html_url: https://github.com/sabuhish
|
||||
- name: titiler
|
||||
html_url: https://github.com/developmentseed/titiler
|
||||
stars: 1016
|
||||
owner_login: developmentseed
|
||||
owner_html_url: https://github.com/developmentseed
|
||||
- name: every-pdf
|
||||
html_url: https://github.com/DDULDDUCK/every-pdf
|
||||
stars: 1004
|
||||
owner_login: DDULDDUCK
|
||||
owner_html_url: https://github.com/DDULDDUCK
|
||||
- name: autollm
|
||||
html_url: https://github.com/viddexa/autollm
|
||||
stars: 1003
|
||||
owner_login: viddexa
|
||||
owner_html_url: https://github.com/viddexa
|
||||
- name: lanarky
|
||||
html_url: https://github.com/ajndkr/lanarky
|
||||
stars: 996
|
||||
owner_login: ajndkr
|
||||
owner_html_url: https://github.com/ajndkr
|
||||
|
||||
@@ -15,7 +15,7 @@ sodaMelon:
|
||||
url: https://github.com/sodaMelon
|
||||
ceb10n:
|
||||
login: ceb10n
|
||||
count: 116
|
||||
count: 117
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/235213?u=edcce471814a1eba9f0cdaa4cd0de18921a940a6&v=4
|
||||
url: https://github.com/ceb10n
|
||||
tokusumi:
|
||||
@@ -23,16 +23,16 @@ tokusumi:
|
||||
count: 104
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/41147016?u=55010621aece725aa702270b54fed829b6a1fe60&v=4
|
||||
url: https://github.com/tokusumi
|
||||
hard-coders:
|
||||
login: hard-coders
|
||||
count: 96
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9651103?u=78d12d1acdf853c817700145e73de7fd9e5d068b&v=4
|
||||
url: https://github.com/hard-coders
|
||||
hasansezertasan:
|
||||
login: hasansezertasan
|
||||
count: 95
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/13135006?u=99f0b0f0fc47e88e8abb337b4447357939ef93e7&v=4
|
||||
url: https://github.com/hasansezertasan
|
||||
hard-coders:
|
||||
login: hard-coders
|
||||
count: 93
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9651103?u=95db33927bbff1ed1c07efddeb97ac2ff33068ed&v=4
|
||||
url: https://github.com/hard-coders
|
||||
alv2017:
|
||||
login: alv2017
|
||||
count: 88
|
||||
@@ -40,7 +40,7 @@ alv2017:
|
||||
url: https://github.com/alv2017
|
||||
nazarepiedady:
|
||||
login: nazarepiedady
|
||||
count: 86
|
||||
count: 87
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31008635?u=f69ddc4ea8bda3bdfac7aa0e2ea38de282e6ee2d&v=4
|
||||
url: https://github.com/nazarepiedady
|
||||
AlertRED:
|
||||
@@ -48,6 +48,11 @@ AlertRED:
|
||||
count: 81
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/15695000?u=f5a4944c6df443030409c88da7d7fa0b7ead985c&v=4
|
||||
url: https://github.com/AlertRED
|
||||
tiangolo:
|
||||
login: tiangolo
|
||||
count: 73
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
Alexandrhub:
|
||||
login: Alexandrhub
|
||||
count: 68
|
||||
@@ -63,21 +68,16 @@ cassiobotaro:
|
||||
count: 62
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3127847?u=a08022b191ddbd0a6159b2981d9d878b6d5bb71f&v=4
|
||||
url: https://github.com/cassiobotaro
|
||||
mattwang44:
|
||||
login: mattwang44
|
||||
count: 61
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/24987826?u=58e37fb3927b9124b458945ac4c97aa0f1062d85&v=4
|
||||
url: https://github.com/mattwang44
|
||||
nilslindemann:
|
||||
login: nilslindemann
|
||||
count: 59
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6892179?u=1dca6a22195d6cd1ab20737c0e19a4c55d639472&v=4
|
||||
url: https://github.com/nilslindemann
|
||||
mattwang44:
|
||||
login: mattwang44
|
||||
count: 59
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/24987826?u=58e37fb3927b9124b458945ac4c97aa0f1062d85&v=4
|
||||
url: https://github.com/mattwang44
|
||||
tiangolo:
|
||||
login: tiangolo
|
||||
count: 56
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
Laineyzhang55:
|
||||
login: Laineyzhang55
|
||||
count: 48
|
||||
@@ -88,6 +88,11 @@ Kludex:
|
||||
count: 47
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
YuriiMotov:
|
||||
login: YuriiMotov
|
||||
count: 46
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=b9b13d598dddfab529a52d264df80a900bfe7060&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
komtaki:
|
||||
login: komtaki
|
||||
count: 45
|
||||
@@ -118,11 +123,6 @@ Winand:
|
||||
count: 40
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/53390?u=bb0e71a2fc3910a8e0ee66da67c33de40ea695f8&v=4
|
||||
url: https://github.com/Winand
|
||||
YuriiMotov:
|
||||
login: YuriiMotov
|
||||
count: 40
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=b9b13d598dddfab529a52d264df80a900bfe7060&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
solomein-sv:
|
||||
login: solomein-sv
|
||||
count: 38
|
||||
@@ -138,6 +138,11 @@ alejsdev:
|
||||
count: 37
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/90076947?u=85ceac49fb87138aebe8d663912e359447329090&v=4
|
||||
url: https://github.com/alejsdev
|
||||
mezgoodle:
|
||||
login: mezgoodle
|
||||
count: 37
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/41520940?u=4a9c765af688389d54296845d18b8f6cd6ddf09a&v=4
|
||||
url: https://github.com/mezgoodle
|
||||
stlucasgarcia:
|
||||
login: stlucasgarcia
|
||||
count: 36
|
||||
@@ -153,11 +158,6 @@ timothy-jeong:
|
||||
count: 36
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/53824764?u=db3d0cea2f5fab64d810113c5039a369699a2774&v=4
|
||||
url: https://github.com/timothy-jeong
|
||||
mezgoodle:
|
||||
login: mezgoodle
|
||||
count: 35
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/41520940?u=4a9c765af688389d54296845d18b8f6cd6ddf09a&v=4
|
||||
url: https://github.com/mezgoodle
|
||||
rjNemo:
|
||||
login: rjNemo
|
||||
count: 34
|
||||
@@ -173,6 +173,11 @@ akarev0:
|
||||
count: 33
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/53393089?u=6e528bb4789d56af887ce6fe237bea4010885406&v=4
|
||||
url: https://github.com/akarev0
|
||||
Vincy1230:
|
||||
login: Vincy1230
|
||||
count: 33
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/81342412?u=ab5e256a4077a4a91f3f9cd2115ba80780454cbe&v=4
|
||||
url: https://github.com/Vincy1230
|
||||
romashevchenko:
|
||||
login: romashevchenko
|
||||
count: 32
|
||||
@@ -183,11 +188,6 @@ LorhanSohaky:
|
||||
count: 30
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16273730?u=095b66f243a2cd6a0aadba9a095009f8aaf18393&v=4
|
||||
url: https://github.com/LorhanSohaky
|
||||
Vincy1230:
|
||||
login: Vincy1230
|
||||
count: 30
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/81342412?u=ab5e256a4077a4a91f3f9cd2115ba80780454cbe&v=4
|
||||
url: https://github.com/Vincy1230
|
||||
black-redoc:
|
||||
login: black-redoc
|
||||
count: 29
|
||||
@@ -250,7 +250,7 @@ mycaule:
|
||||
url: https://github.com/mycaule
|
||||
Aruelius:
|
||||
login: Aruelius
|
||||
count: 24
|
||||
count: 25
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25380989?u=574f8cfcda3ea77a3f81884f6b26a97068e36a9d&v=4
|
||||
url: https://github.com/Aruelius
|
||||
wisderfin:
|
||||
@@ -263,6 +263,11 @@ OzgunCaglarArslan:
|
||||
count: 24
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/86166426?v=4
|
||||
url: https://github.com/OzgunCaglarArslan
|
||||
ycd:
|
||||
login: ycd
|
||||
count: 23
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62724709?u=f1e7bae394a315da950912c92dc861a8eaf95d4c&v=4
|
||||
url: https://github.com/ycd
|
||||
sh0nk:
|
||||
login: sh0nk
|
||||
count: 23
|
||||
@@ -288,11 +293,6 @@ Attsun1031:
|
||||
count: 20
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1175560?v=4
|
||||
url: https://github.com/Attsun1031
|
||||
ycd:
|
||||
login: ycd
|
||||
count: 20
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62724709?u=f1e7bae394a315da950912c92dc861a8eaf95d4c&v=4
|
||||
url: https://github.com/ycd
|
||||
delhi09:
|
||||
login: delhi09
|
||||
count: 20
|
||||
@@ -418,6 +418,11 @@ mattkoehne:
|
||||
count: 14
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/80362153?v=4
|
||||
url: https://github.com/mattkoehne
|
||||
maru0123-2004:
|
||||
login: maru0123-2004
|
||||
count: 14
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/43961566?u=16ed8603a4d6a4665cb6c53a7aece6f31379b769&v=4
|
||||
url: https://github.com/maru0123-2004
|
||||
jovicon:
|
||||
login: jovicon
|
||||
count: 13
|
||||
@@ -443,6 +448,11 @@ impocode:
|
||||
count: 13
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109408819?u=9cdfc5ccb31a2094c520f41b6087012fa9048982&v=4
|
||||
url: https://github.com/impocode
|
||||
waketzheng:
|
||||
login: waketzheng
|
||||
count: 13
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/35413830?u=df19e4fd5bb928e7d086e053ef26a46aad23bf84&v=4
|
||||
url: https://github.com/waketzheng
|
||||
wesinalves:
|
||||
login: wesinalves
|
||||
count: 13
|
||||
@@ -538,21 +548,16 @@ Lufa1u:
|
||||
count: 11
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/112495876?u=087658920ed9e74311597bdd921d8d2de939d276&v=4
|
||||
url: https://github.com/Lufa1u
|
||||
waketzheng:
|
||||
login: waketzheng
|
||||
count: 11
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/35413830?u=df19e4fd5bb928e7d086e053ef26a46aad23bf84&v=4
|
||||
url: https://github.com/waketzheng
|
||||
KNChiu:
|
||||
login: KNChiu
|
||||
count: 11
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/36751646?v=4
|
||||
url: https://github.com/KNChiu
|
||||
maru0123-2004:
|
||||
login: maru0123-2004
|
||||
Zhongheng-Cheng:
|
||||
login: Zhongheng-Cheng
|
||||
count: 11
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/43961566?u=16ed8603a4d6a4665cb6c53a7aece6f31379b769&v=4
|
||||
url: https://github.com/maru0123-2004
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/95612344?u=a0f7730a3cc7486827965e01a119ad610bda4b0a&v=4
|
||||
url: https://github.com/Zhongheng-Cheng
|
||||
mariacamilagl:
|
||||
login: mariacamilagl
|
||||
count: 10
|
||||
@@ -608,16 +613,16 @@ nick-cjyx9:
|
||||
count: 10
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/119087246?u=7227a2de948c68fb8396d5beff1ee5b0e057c42e&v=4
|
||||
url: https://github.com/nick-cjyx9
|
||||
marcelomarkus:
|
||||
login: marcelomarkus
|
||||
count: 10
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/20115018?u=dda090ce9160ef0cd2ff69b1e5ea741283425cba&v=4
|
||||
url: https://github.com/marcelomarkus
|
||||
lucasbalieiro:
|
||||
login: lucasbalieiro
|
||||
count: 10
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37416577?u=dad91601ee4f40458d691774ec439aff308344d7&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37416577?u=d144221c34c08adac8b20e1833d776ffa1c4b1d0&v=4
|
||||
url: https://github.com/lucasbalieiro
|
||||
Zhongheng-Cheng:
|
||||
login: Zhongheng-Cheng
|
||||
count: 10
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/95612344?u=a0f7730a3cc7486827965e01a119ad610bda4b0a&v=4
|
||||
url: https://github.com/Zhongheng-Cheng
|
||||
RunningIkkyu:
|
||||
login: RunningIkkyu
|
||||
count: 9
|
||||
@@ -668,11 +673,6 @@ yodai-yodai:
|
||||
count: 9
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7031039?u=4f3593f5931892b931a745cfab846eff6e9332e7&v=4
|
||||
url: https://github.com/yodai-yodai
|
||||
marcelomarkus:
|
||||
login: marcelomarkus
|
||||
count: 9
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/20115018?u=dda090ce9160ef0cd2ff69b1e5ea741283425cba&v=4
|
||||
url: https://github.com/marcelomarkus
|
||||
JoaoGustavoRogel:
|
||||
login: JoaoGustavoRogel
|
||||
count: 9
|
||||
@@ -683,6 +683,11 @@ Yarous:
|
||||
count: 9
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/61277193?u=5b462347458a373b2d599c6f416d2b75eddbffad&v=4
|
||||
url: https://github.com/Yarous
|
||||
Pyth3rEx:
|
||||
login: Pyth3rEx
|
||||
count: 9
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/26427764?u=087724f74d813c95925d51e354554bd4b6d6bb60&v=4
|
||||
url: https://github.com/Pyth3rEx
|
||||
dimaqq:
|
||||
login: dimaqq
|
||||
count: 8
|
||||
@@ -1023,6 +1028,11 @@ devluisrodrigues:
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/21125286?v=4
|
||||
url: https://github.com/11kkw
|
||||
EdmilsonRodrigues:
|
||||
login: EdmilsonRodrigues
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62777025?u=217d6f3cd6cc750bb8818a3af7726c8d74eb7c2d&v=4
|
||||
url: https://github.com/EdmilsonRodrigues
|
||||
lpdswing:
|
||||
login: lpdswing
|
||||
count: 4
|
||||
@@ -1163,6 +1173,11 @@ AbolfazlKameli:
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/120686133?u=af8f025278cce0d489007071254e4055df60b78c&v=4
|
||||
url: https://github.com/AbolfazlKameli
|
||||
SBillion:
|
||||
login: SBillion
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1070649?u=3ab493dfc88b39da0eb1600e3b8e7df1c90a5dee&v=4
|
||||
url: https://github.com/SBillion
|
||||
tyronedamasceno:
|
||||
login: tyronedamasceno
|
||||
count: 3
|
||||
@@ -1211,7 +1226,7 @@ phamquanganh31101998:
|
||||
peebbv6364:
|
||||
login: peebbv6364
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/26784747?u=75583df215ee01a5cd2dc646aecb81e7dbd33d06&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/26784747?u=3bf07017eb4f4fa3639ba8d4ed19980a34bf8f90&v=4
|
||||
url: https://github.com/peebbv6364
|
||||
mrparalon:
|
||||
login: mrparalon
|
||||
@@ -1413,11 +1428,6 @@ Mohammad222PR:
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/116789737?u=25810a5fe049d2f1618e2e7417cea011cc353ce4&v=4
|
||||
url: https://github.com/Mohammad222PR
|
||||
EdmilsonRodrigues:
|
||||
login: EdmilsonRodrigues
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62777025?u=217d6f3cd6cc750bb8818a3af7726c8d74eb7c2d&v=4
|
||||
url: https://github.com/EdmilsonRodrigues
|
||||
blaisep:
|
||||
login: blaisep
|
||||
count: 2
|
||||
@@ -1838,11 +1848,11 @@ NavesSapnis:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/79222417?u=b5b10291b8e9130ca84fd20f0a641e04ed94b6b1&v=4
|
||||
url: https://github.com/NavesSapnis
|
||||
eqsdxr:
|
||||
login: eqsdxr
|
||||
isgin01:
|
||||
login: isgin01
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/157279130?u=7927dc0366995334f9a18c3204a41d3a34d6d96f&v=4
|
||||
url: https://github.com/eqsdxr
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/157279130?u=ddffde10876b50f35dc90d1337f507a630530a6a&v=4
|
||||
url: https://github.com/isgin01
|
||||
syedasamina56:
|
||||
login: syedasamina56
|
||||
count: 2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
nilslindemann:
|
||||
login: nilslindemann
|
||||
count: 125
|
||||
count: 130
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6892179?u=1dca6a22195d6cd1ab20737c0e19a4c55d639472&v=4
|
||||
url: https://github.com/nilslindemann
|
||||
jaystone776:
|
||||
@@ -28,6 +28,11 @@ SwftAlpc:
|
||||
count: 23
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/52768429?u=6a3aa15277406520ad37f6236e89466ed44bc5b8&v=4
|
||||
url: https://github.com/SwftAlpc
|
||||
tiangolo:
|
||||
login: tiangolo
|
||||
count: 22
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
hasansezertasan:
|
||||
login: hasansezertasan
|
||||
count: 22
|
||||
@@ -46,7 +51,7 @@ AlertRED:
|
||||
hard-coders:
|
||||
login: hard-coders
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9651103?u=95db33927bbff1ed1c07efddeb97ac2ff33068ed&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9651103?u=78d12d1acdf853c817700145e73de7fd9e5d068b&v=4
|
||||
url: https://github.com/hard-coders
|
||||
Joao-Pedro-P-Holanda:
|
||||
login: Joao-Pedro-P-Holanda
|
||||
@@ -103,11 +108,6 @@ pablocm83:
|
||||
count: 8
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/28315068?u=3310fbb05bb8bfc50d2c48b6cb64ac9ee4a14549&v=4
|
||||
url: https://github.com/pablocm83
|
||||
tiangolo:
|
||||
login: tiangolo
|
||||
count: 7
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
ptt3199:
|
||||
login: ptt3199
|
||||
count: 7
|
||||
@@ -126,13 +126,18 @@ batlopes:
|
||||
lucasbalieiro:
|
||||
login: lucasbalieiro
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37416577?u=dad91601ee4f40458d691774ec439aff308344d7&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37416577?u=d144221c34c08adac8b20e1833d776ffa1c4b1d0&v=4
|
||||
url: https://github.com/lucasbalieiro
|
||||
Alexandrhub:
|
||||
login: Alexandrhub
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/119126536?u=9fc0d48f3307817bafecc5861eb2168401a6cb04&v=4
|
||||
url: https://github.com/Alexandrhub
|
||||
YuriiMotov:
|
||||
login: YuriiMotov
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=b9b13d598dddfab529a52d264df80a900bfe7060&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
Serrones:
|
||||
login: Serrones
|
||||
count: 5
|
||||
@@ -358,11 +363,6 @@ ruzia:
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/24503?v=4
|
||||
url: https://github.com/ruzia
|
||||
YuriiMotov:
|
||||
login: YuriiMotov
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=b9b13d598dddfab529a52d264df80a900bfe7060&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
izaguerreiro:
|
||||
login: izaguerreiro
|
||||
count: 2
|
||||
|
||||
@@ -6,7 +6,7 @@ Tests added here will be seen by all designers of language specific prompts.
|
||||
|
||||
Use as follows:
|
||||
|
||||
* Have a language specific prompt – `docs/{language code}/llm-prompt.md`.
|
||||
* Have a language specific prompt - `docs/{language code}/llm-prompt.md`.
|
||||
* Do a fresh translation of this document into your desired target language (see e.g. the `translate-page` command of the `translate.py`). This will create the translation under `docs/{language code}/docs/_llm-test.md`.
|
||||
* Check if things are okay in the translation.
|
||||
* If necessary, improve your language specific prompt, the general prompt, or the English document.
|
||||
|
||||
@@ -7,6 +7,33 @@ hide:
|
||||
|
||||
## Latest Changes
|
||||
|
||||
### Translations
|
||||
|
||||
* 🔧 Add LLM prompt file for Turkish, generated from the existing translations. PR [#14547](https://github.com/fastapi/fastapi/pull/14547) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔧 Add LLM prompt file for Traditional Chinese, generated from the existing translations. PR [#14550](https://github.com/fastapi/fastapi/pull/14550) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔧 Add LLM prompt file for Simplified Chinese, generated from the existing translations. PR [#14549](https://github.com/fastapi/fastapi/pull/14549) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Internal
|
||||
|
||||
* 👥 Update FastAPI People - Sponsors. PR [#14626](https://github.com/fastapi/fastapi/pull/14626) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👥 Update FastAPI GitHub topic repositories. PR [#14630](https://github.com/fastapi/fastapi/pull/14630) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👥 Update FastAPI People - Contributors and Translators. PR [#14625](https://github.com/fastapi/fastapi/pull/14625) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🌐 Update translation prompts. PR [#14619](https://github.com/fastapi/fastapi/pull/14619) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔨 Update LLM translation script to guide reviewers to change the prompt. PR [#14614](https://github.com/fastapi/fastapi/pull/14614) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Do not run translations on cron while finishing updating existing languages. PR [#14613](https://github.com/fastapi/fastapi/pull/14613) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔥 Remove test variants for Pydantic v1 in test_request_params. PR [#14612](https://github.com/fastapi/fastapi/pull/14612) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔥 Remove Pydantic v1 specific test variants. PR [#14611](https://github.com/fastapi/fastapi/pull/14611) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.128.0
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
* ➖ Drop support for `pydantic.v1`. PR [#14609](https://github.com/fastapi/fastapi/pull/14609) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Internal
|
||||
|
||||
* ✅ Run performance tests only on Pydantic v2. PR [#14608](https://github.com/fastapi/fastapi/pull/14608) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.127.1
|
||||
|
||||
### Refactors
|
||||
|
||||
@@ -6,23 +6,23 @@ Language code: ja.
|
||||
|
||||
### Grammar and tone
|
||||
|
||||
1) Use polite, instructional Japanese (です/ます調).
|
||||
2) Keep the tone concise and technical (match existing Japanese FastAPI docs).
|
||||
- Use polite, instructional Japanese (です/ます調).
|
||||
- Keep the tone concise and technical (match existing Japanese FastAPI docs).
|
||||
|
||||
### Headings
|
||||
|
||||
1) Follow the existing Japanese style: short, descriptive headings (often noun phrases), e.g. 「チェック」.
|
||||
2) Do not add a trailing period at the end of headings.
|
||||
- Follow the existing Japanese style: short, descriptive headings (often noun phrases), e.g. 「チェック」.
|
||||
- Do not add a trailing period at the end of headings.
|
||||
|
||||
### Quotes
|
||||
|
||||
1) Prefer Japanese corner brackets 「」 in normal prose when quoting a term.
|
||||
2) Do not change quotes inside inline code, code blocks, URLs, or file paths.
|
||||
- Prefer Japanese corner brackets 「」 in normal prose when quoting a term.
|
||||
- Do not change quotes inside inline code, code blocks, URLs, or file paths.
|
||||
|
||||
### Ellipsis
|
||||
|
||||
1) Keep ellipsis style consistent with existing Japanese docs (commonly `...`).
|
||||
2) Never change `...` in code, URLs, or CLI examples.
|
||||
- Keep ellipsis style consistent with existing Japanese docs (commonly `...`).
|
||||
- Never change `...` in code, URLs, or CLI examples.
|
||||
|
||||
### Preferred translations / glossary
|
||||
|
||||
|
||||
@@ -6,23 +6,23 @@ Language code: ko.
|
||||
|
||||
### Grammar and tone
|
||||
|
||||
1) Use polite, instructional Korean (e.g. 합니다/하세요 style).
|
||||
2) Keep the tone consistent with the existing Korean FastAPI docs.
|
||||
- Use polite, instructional Korean (e.g. 합니다/하세요 style).
|
||||
- Keep the tone consistent with the existing Korean FastAPI docs.
|
||||
|
||||
### Headings
|
||||
|
||||
1) Follow existing Korean heading style (short, action-oriented headings like “확인하기”).
|
||||
2) Do not add trailing punctuation to headings.
|
||||
- Follow existing Korean heading style (short, action-oriented headings like “확인하기”).
|
||||
- Do not add trailing punctuation to headings.
|
||||
|
||||
### Quotes
|
||||
|
||||
1) Keep quote style consistent with the existing Korean docs.
|
||||
2) Never change quotes inside inline code, code blocks, URLs, or file paths.
|
||||
- Keep quote style consistent with the existing Korean docs.
|
||||
- Never change quotes inside inline code, code blocks, URLs, or file paths.
|
||||
|
||||
### Ellipsis
|
||||
|
||||
1) Keep ellipsis style consistent with existing Korean docs (often `...`).
|
||||
2) Never change `...` in code, URLs, or CLI examples.
|
||||
- Keep ellipsis style consistent with existing Korean docs (often `...`).
|
||||
- Never change `...` in code, URLs, or CLI examples.
|
||||
|
||||
### Preferred translations / glossary
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@ This page hasn’t been translated into your language yet. 🌍
|
||||
|
||||
We’re currently switching to an automated translation system 🤖, which will help keep all translations complete and up to date.
|
||||
|
||||
Learn more: [Contributing – Translations](https://fastapi.tiangolo.com/contributing/#translations){.internal-link target=_blank}
|
||||
Learn more: [Contributing - Translations](https://fastapi.tiangolo.com/contributing/#translations){.internal-link target=_blank}
|
||||
|
||||
///
|
||||
|
||||
@@ -14,15 +14,15 @@ When translating documentation into Portuguese, use neutral and widely understan
|
||||
|
||||
For the next terms, use the following translations:
|
||||
|
||||
* «/// check»: «/// check | Verifique»
|
||||
* «/// danger»: «/// danger | Cuidado»
|
||||
* «/// info»: «/// info | Informação»
|
||||
* «/// note | Technical Details»: «/// note | Detalhes Técnicos»
|
||||
* «/// info | Very Technical Details»: «/// note | Detalhes Técnicos Avançados»
|
||||
* «/// note»: «/// note | Nota»
|
||||
* «/// tip»: «/// tip | Dica»
|
||||
* «/// warning»: «/// warning | Atenção»
|
||||
* «(you should)»: «(você deveria)»
|
||||
* /// check: /// check | Verifique
|
||||
* /// danger: /// danger | Cuidado
|
||||
* /// info: /// info | Informação
|
||||
* /// note | Technical Details: /// note | Detalhes Técnicos
|
||||
* /// info | Very Technical Details: /// note | Detalhes Técnicos Avançados
|
||||
* /// note: /// note | Nota
|
||||
* /// tip: /// tip | Dica
|
||||
* /// warning: /// warning | Atenção
|
||||
* (you should): (você deveria)
|
||||
* async context manager: gerenciador de contexto assíncrono
|
||||
* autocomplete: autocompletar
|
||||
* autocompletion: preenchimento automático
|
||||
|
||||
52
docs/tr/llm-prompt.md
Normal file
52
docs/tr/llm-prompt.md
Normal file
@@ -0,0 +1,52 @@
|
||||
### Target language
|
||||
|
||||
Translate to Turkish (Türkçe).
|
||||
|
||||
Language code: tr.
|
||||
|
||||
### Grammar and tone
|
||||
|
||||
- Use instructional Turkish, consistent with existing Turkish docs.
|
||||
- Use imperative/guide language when appropriate (e.g. “açalım”, “gidin”, “kopyalayalım”).
|
||||
|
||||
### Headings
|
||||
|
||||
- Follow existing Turkish heading style (Title Case where used; no trailing period).
|
||||
|
||||
### Quotes
|
||||
|
||||
- Alıntı stili mevcut Türkçe dokümanlarla tutarlı tutun (genellikle metin içinde ASCII tırnak işaretleri kullanılır).
|
||||
- Satır içi kod, kod blokları, URL'ler veya dosya yolları içindeki tırnak işaretlerini asla değiştirmeyin.
|
||||
|
||||
### Ellipsis
|
||||
|
||||
- Üç nokta (...) stili mevcut Türkçe dokümanlarla tutarlı tutun.
|
||||
- Kod, URL veya CLI örneklerindeki `...` ifadesini asla değiştirmeyin.
|
||||
|
||||
### Preferred translations / glossary
|
||||
|
||||
Do not translate technical terms like path, route, request, response, query, body, cookie, and header, keep them as is.
|
||||
|
||||
- Suffixing is very important, when adding Turkish suffixes to the English words, do that based on the pronunciation of the word and with an apostrophe.
|
||||
|
||||
- Suffixes also changes based on what word comes next in Turkish too, here is an example:
|
||||
|
||||
"Server'a gelen request'leri intercept... " or this could have been "request'e", "request'i" etc.
|
||||
|
||||
- Some words are tricky like "path'e" can't be used like "path'a" but it could have been "path'i" "path'leri" etc.
|
||||
|
||||
- You can use a more instructional style, that is consistent with the document, you can add the Turkish version of the term in parenthesis if it is not something very obvious, or an advanced concept, but do not over do it, do it only the first time it is mentioned, but keep the English term as the primary word.
|
||||
|
||||
### `///` admonitions
|
||||
|
||||
- Keep the admonition keyword in English (do not translate `note`, `tip`, etc.).
|
||||
- If a title is present, prefer these canonical titles:
|
||||
|
||||
- `/// note | Not`
|
||||
- `/// note | Teknik Detaylar`
|
||||
- `/// tip | İpucu`
|
||||
- `/// warning | Uyarı`
|
||||
- `/// info | Bilgi`
|
||||
- `/// check | Ek bilgi`
|
||||
|
||||
Prefer `İpucu` over `Ipucu`.
|
||||
@@ -6,23 +6,23 @@ Language code: uk.
|
||||
|
||||
### Grammar and tone
|
||||
|
||||
1) Use polite/formal address consistent with existing Ukrainian docs (use “ви/ваш”).
|
||||
2) Keep the tone concise and technical.
|
||||
- Use polite/formal address consistent with existing Ukrainian docs (use “ви/ваш”).
|
||||
- Keep the tone concise and technical.
|
||||
|
||||
### Headings
|
||||
|
||||
1) Follow existing Ukrainian heading style; keep headings short and instructional.
|
||||
2) Do not add trailing punctuation to headings.
|
||||
- Follow existing Ukrainian heading style; keep headings short and instructional.
|
||||
- Do not add trailing punctuation to headings.
|
||||
|
||||
### Quotes
|
||||
|
||||
1) Prefer Ukrainian guillemets «…» for quoted terms in prose, matching existing Ukrainian docs.
|
||||
2) Never change quotes inside inline code, code blocks, URLs, or file paths.
|
||||
- Prefer Ukrainian guillemets «…» for quoted terms in prose, matching existing Ukrainian docs.
|
||||
- Never change quotes inside inline code, code blocks, URLs, or file paths.
|
||||
|
||||
### Ellipsis
|
||||
|
||||
1) Keep ellipsis style consistent with existing Ukrainian docs.
|
||||
2) Never change `...` in code, URLs, or CLI examples.
|
||||
- Keep ellipsis style consistent with existing Ukrainian docs.
|
||||
- Never change `...` in code, URLs, or CLI examples.
|
||||
|
||||
### Preferred translations / glossary
|
||||
|
||||
@@ -35,8 +35,8 @@ Use the following preferred translations when they apply in documentation prose:
|
||||
|
||||
### `///` admonitions
|
||||
|
||||
1) Keep the admonition keyword in English (do not translate `note`, `tip`, etc.).
|
||||
2) If a title is present, prefer these canonical titles (choose one canonical form where variants exist):
|
||||
- Keep the admonition keyword in English (do not translate `note`, `tip`, etc.).
|
||||
- If a title is present, prefer these canonical titles (choose one canonical form where variants exist):
|
||||
|
||||
- `/// note | Примітка`
|
||||
- `/// note | Технічні деталі`
|
||||
|
||||
60
docs/zh-hant/llm-prompt.md
Normal file
60
docs/zh-hant/llm-prompt.md
Normal file
@@ -0,0 +1,60 @@
|
||||
### Target language
|
||||
|
||||
Translate to Traditional Chinese (繁體中文).
|
||||
|
||||
Language code: zh-hant.
|
||||
|
||||
### Grammar and tone
|
||||
|
||||
- Use clear, concise technical Traditional Chinese consistent with existing docs.
|
||||
- Address the reader naturally (commonly using “你/你的”).
|
||||
|
||||
### Headings
|
||||
|
||||
- Follow existing Traditional Chinese heading style (short and descriptive).
|
||||
- Do not add trailing punctuation to headings.
|
||||
|
||||
### Quotes and punctuation
|
||||
|
||||
- Keep punctuation style consistent with existing Traditional Chinese docs (they often mix English terms like “FastAPI” with Chinese text).
|
||||
- Never change punctuation inside inline code, code blocks, URLs, or file paths.
|
||||
- For more details, please follow the [Chinese Copywriting Guidelines](https://github.com/sparanoid/chinese-copywriting-guidelines).
|
||||
|
||||
### Ellipsis
|
||||
|
||||
- Keep ellipsis style consistent within each document, prefer `...` over `……`.
|
||||
- Never change ellipsis in code, URLs, or CLI examples.
|
||||
|
||||
### Preferred translations / glossary
|
||||
|
||||
- Should avoid using simplified Chinese characters and terms. Always examine if the translation can be easily comprehended by the Traditional Chinese readers.
|
||||
- For some Python-specific terms like "pickle", "list", "dict" etc, we don't have to translate them.
|
||||
- Use the following preferred translations when they apply in documentation prose:
|
||||
|
||||
- request (HTTP): 請求
|
||||
- response (HTTP): 回應
|
||||
- path operation: 路徑操作
|
||||
- path operation function: 路徑操作函式
|
||||
|
||||
The translation can optionally include the original English text only in the first occurrence of each page (e.g. "路徑操作 (path operation)") if the translation is hard to be comprehended by most of the Chinese readers.
|
||||
|
||||
### `///` admonitions
|
||||
|
||||
1) Keep the admonition keyword in English (do not translate `note`, `tip`, etc.).
|
||||
2) Many Traditional Chinese docs currently omit titles in `///` blocks; that is OK.
|
||||
3) If a generic title is present, prefer these canonical titles:
|
||||
|
||||
- `/// note | 注意`
|
||||
|
||||
Notes:
|
||||
|
||||
- `details` blocks exist; keep `/// details` as-is and translate only the title after `|`.
|
||||
- Example canonical titles used in existing docs:
|
||||
|
||||
```
|
||||
/// details | 上述指令的含義
|
||||
```
|
||||
|
||||
```
|
||||
/// details | 關於 `requirements.txt`
|
||||
```
|
||||
46
docs/zh/llm-prompt.md
Normal file
46
docs/zh/llm-prompt.md
Normal file
@@ -0,0 +1,46 @@
|
||||
### Target language
|
||||
|
||||
Translate to Simplified Chinese (简体中文).
|
||||
|
||||
Language code: zh.
|
||||
|
||||
### Grammar and tone
|
||||
|
||||
- Use clear, concise technical Chinese consistent with existing docs.
|
||||
- Address the reader naturally (commonly using “你/你的”).
|
||||
|
||||
### Headings
|
||||
|
||||
- Follow existing Simplified Chinese heading style (short and descriptive).
|
||||
- Do not add trailing punctuation to headings.
|
||||
- If a heading contains only the name of a FastAPI feature, do not translate it.
|
||||
|
||||
### Quotes and punctuation
|
||||
|
||||
- Keep punctuation style consistent with existing Simplified Chinese docs (they often mix English terms like “FastAPI” with Chinese text).
|
||||
- Never change punctuation inside inline code, code blocks, URLs, or file paths.
|
||||
|
||||
### Ellipsis
|
||||
|
||||
- Keep ellipsis style consistent within each document, prefer `...` over `……`.
|
||||
- Never change ellipsis in code, URLs, or CLI examples.
|
||||
|
||||
### Preferred translations / glossary
|
||||
|
||||
Use the following preferred translations when they apply in documentation prose:
|
||||
|
||||
- request (HTTP): 请求
|
||||
- response (HTTP): 响应
|
||||
- path operation: 路径操作
|
||||
- path operation function: 路径操作函数
|
||||
|
||||
### `///` admonitions
|
||||
|
||||
- Keep the admonition keyword in English (do not translate `note`, `tip`, etc.).
|
||||
- If a title is present, prefer these canonical titles:
|
||||
|
||||
- `/// tip | 提示`
|
||||
- `/// note | 注意`
|
||||
- `/// warning | 警告`
|
||||
- `/// info | 信息`
|
||||
- `/// danger | 危险`
|
||||
@@ -1,20 +0,0 @@
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.temp_pydantic_v1_params import Form
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FormData(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
|
||||
|
||||
@app.post("/login/")
|
||||
async def login(data: Annotated[FormData, Form()]):
|
||||
return data
|
||||
@@ -1,18 +0,0 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.temp_pydantic_v1_params import Form
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class FormData(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
|
||||
|
||||
@app.post("/login/")
|
||||
async def login(data: FormData = Form()):
|
||||
return data
|
||||
@@ -1,6 +1,6 @@
|
||||
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
||||
|
||||
__version__ = "0.127.1"
|
||||
__version__ = "0.128.0"
|
||||
|
||||
from starlette import status as status
|
||||
|
||||
|
||||
@@ -1,43 +1,9 @@
|
||||
from .main import BaseConfig as BaseConfig
|
||||
from .main import PydanticSchemaGenerationError as PydanticSchemaGenerationError
|
||||
from .main import RequiredParam as RequiredParam
|
||||
from .main import Undefined as Undefined
|
||||
from .main import UndefinedType as UndefinedType
|
||||
from .main import Url as Url
|
||||
from .main import Validator as Validator
|
||||
from .main import _get_model_config as _get_model_config
|
||||
from .main import _is_error_wrapper as _is_error_wrapper
|
||||
from .main import _is_model_class as _is_model_class
|
||||
from .main import _is_model_field as _is_model_field
|
||||
from .main import _is_undefined as _is_undefined
|
||||
from .main import _model_dump as _model_dump
|
||||
from .main import copy_field_info as copy_field_info
|
||||
from .main import create_body_model as create_body_model
|
||||
from .main import evaluate_forwardref as evaluate_forwardref
|
||||
from .main import get_annotation_from_field_info as get_annotation_from_field_info
|
||||
from .main import get_cached_model_fields as get_cached_model_fields
|
||||
from .main import get_compat_model_name_map as get_compat_model_name_map
|
||||
from .main import get_definitions as get_definitions
|
||||
from .main import get_missing_field_error as get_missing_field_error
|
||||
from .main import get_schema_from_model_field as get_schema_from_model_field
|
||||
from .main import is_bytes_field as is_bytes_field
|
||||
from .main import is_bytes_sequence_field as is_bytes_sequence_field
|
||||
from .main import is_scalar_field as is_scalar_field
|
||||
from .main import is_scalar_sequence_field as is_scalar_sequence_field
|
||||
from .main import is_sequence_field as is_sequence_field
|
||||
from .main import serialize_sequence_value as serialize_sequence_value
|
||||
from .main import (
|
||||
with_info_plain_validator_function as with_info_plain_validator_function,
|
||||
)
|
||||
from .may_v1 import CoreSchema as CoreSchema
|
||||
from .may_v1 import GetJsonSchemaHandler as GetJsonSchemaHandler
|
||||
from .may_v1 import JsonSchemaValue as JsonSchemaValue
|
||||
from .may_v1 import _normalize_errors as _normalize_errors
|
||||
from .model_field import ModelField as ModelField
|
||||
from .shared import PYDANTIC_V2 as PYDANTIC_V2
|
||||
from .shared import PYDANTIC_VERSION_MINOR_TUPLE as PYDANTIC_VERSION_MINOR_TUPLE
|
||||
from .shared import annotation_is_pydantic_v1 as annotation_is_pydantic_v1
|
||||
from .shared import field_annotation_is_scalar as field_annotation_is_scalar
|
||||
from .shared import is_pydantic_v1_model_class as is_pydantic_v1_model_class
|
||||
from .shared import is_pydantic_v1_model_instance as is_pydantic_v1_model_instance
|
||||
from .shared import (
|
||||
is_uploadfile_or_nonable_uploadfile_annotation as is_uploadfile_or_nonable_uploadfile_annotation,
|
||||
)
|
||||
@@ -47,3 +13,29 @@ from .shared import (
|
||||
from .shared import lenient_issubclass as lenient_issubclass
|
||||
from .shared import sequence_types as sequence_types
|
||||
from .shared import value_is_sequence as value_is_sequence
|
||||
from .v2 import BaseConfig as BaseConfig
|
||||
from .v2 import ModelField as ModelField
|
||||
from .v2 import PydanticSchemaGenerationError as PydanticSchemaGenerationError
|
||||
from .v2 import RequiredParam as RequiredParam
|
||||
from .v2 import Undefined as Undefined
|
||||
from .v2 import UndefinedType as UndefinedType
|
||||
from .v2 import Url as Url
|
||||
from .v2 import Validator as Validator
|
||||
from .v2 import _regenerate_error_with_loc as _regenerate_error_with_loc
|
||||
from .v2 import copy_field_info as copy_field_info
|
||||
from .v2 import create_body_model as create_body_model
|
||||
from .v2 import evaluate_forwardref as evaluate_forwardref
|
||||
from .v2 import get_cached_model_fields as get_cached_model_fields
|
||||
from .v2 import get_compat_model_name_map as get_compat_model_name_map
|
||||
from .v2 import get_definitions as get_definitions
|
||||
from .v2 import get_missing_field_error as get_missing_field_error
|
||||
from .v2 import get_schema_from_model_field as get_schema_from_model_field
|
||||
from .v2 import is_bytes_field as is_bytes_field
|
||||
from .v2 import is_bytes_sequence_field as is_bytes_sequence_field
|
||||
from .v2 import is_scalar_field as is_scalar_field
|
||||
from .v2 import is_scalar_sequence_field as is_scalar_sequence_field
|
||||
from .v2 import is_sequence_field as is_sequence_field
|
||||
from .v2 import serialize_sequence_value as serialize_sequence_value
|
||||
from .v2 import (
|
||||
with_info_plain_validator_function as with_info_plain_validator_function,
|
||||
)
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
import sys
|
||||
from collections.abc import Sequence
|
||||
from functools import lru_cache
|
||||
from typing import (
|
||||
Any,
|
||||
)
|
||||
|
||||
from fastapi._compat import may_v1
|
||||
from fastapi._compat.shared import lenient_issubclass
|
||||
from fastapi.types import ModelNameMap
|
||||
from pydantic import BaseModel
|
||||
from typing_extensions import Literal
|
||||
|
||||
from . import v2
|
||||
from .model_field import ModelField
|
||||
from .v2 import BaseConfig as BaseConfig
|
||||
from .v2 import FieldInfo as FieldInfo
|
||||
from .v2 import PydanticSchemaGenerationError as PydanticSchemaGenerationError
|
||||
from .v2 import RequiredParam as RequiredParam
|
||||
from .v2 import Undefined as Undefined
|
||||
from .v2 import UndefinedType as UndefinedType
|
||||
from .v2 import Url as Url
|
||||
from .v2 import Validator as Validator
|
||||
from .v2 import evaluate_forwardref as evaluate_forwardref
|
||||
from .v2 import get_missing_field_error as get_missing_field_error
|
||||
from .v2 import (
|
||||
with_info_plain_validator_function as with_info_plain_validator_function,
|
||||
)
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_cached_model_fields(model: type[BaseModel]) -> list[ModelField]:
|
||||
if lenient_issubclass(model, may_v1.BaseModel):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.get_model_fields(model) # type: ignore[arg-type,return-value]
|
||||
else:
|
||||
from . import v2
|
||||
|
||||
return v2.get_model_fields(model) # type: ignore[return-value]
|
||||
|
||||
|
||||
def _is_undefined(value: object) -> bool:
|
||||
if isinstance(value, may_v1.UndefinedType):
|
||||
return True
|
||||
|
||||
return isinstance(value, v2.UndefinedType)
|
||||
|
||||
|
||||
def _get_model_config(model: BaseModel) -> Any:
|
||||
if isinstance(model, may_v1.BaseModel):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1._get_model_config(model)
|
||||
|
||||
return v2._get_model_config(model)
|
||||
|
||||
|
||||
def _model_dump(
|
||||
model: BaseModel, mode: Literal["json", "python"] = "json", **kwargs: Any
|
||||
) -> Any:
|
||||
if isinstance(model, may_v1.BaseModel):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1._model_dump(model, mode=mode, **kwargs)
|
||||
|
||||
return v2._model_dump(model, mode=mode, **kwargs)
|
||||
|
||||
|
||||
def _is_error_wrapper(exc: Exception) -> bool:
|
||||
if isinstance(exc, may_v1.ErrorWrapper):
|
||||
return True
|
||||
|
||||
return isinstance(exc, v2.ErrorWrapper)
|
||||
|
||||
|
||||
def copy_field_info(*, field_info: FieldInfo, annotation: Any) -> FieldInfo:
|
||||
if isinstance(field_info, may_v1.FieldInfo):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.copy_field_info(field_info=field_info, annotation=annotation)
|
||||
|
||||
return v2.copy_field_info(field_info=field_info, annotation=annotation)
|
||||
|
||||
|
||||
def create_body_model(
|
||||
*, fields: Sequence[ModelField], model_name: str
|
||||
) -> type[BaseModel]:
|
||||
if fields and isinstance(fields[0], may_v1.ModelField):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.create_body_model(fields=fields, model_name=model_name)
|
||||
|
||||
return v2.create_body_model(fields=fields, model_name=model_name) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def get_annotation_from_field_info(
|
||||
annotation: Any, field_info: FieldInfo, field_name: str
|
||||
) -> Any:
|
||||
if isinstance(field_info, may_v1.FieldInfo):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.get_annotation_from_field_info(
|
||||
annotation=annotation, field_info=field_info, field_name=field_name
|
||||
)
|
||||
|
||||
return v2.get_annotation_from_field_info(
|
||||
annotation=annotation, field_info=field_info, field_name=field_name
|
||||
)
|
||||
|
||||
|
||||
def is_bytes_field(field: ModelField) -> bool:
|
||||
if isinstance(field, may_v1.ModelField):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.is_bytes_field(field)
|
||||
|
||||
return v2.is_bytes_field(field) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def is_bytes_sequence_field(field: ModelField) -> bool:
|
||||
if isinstance(field, may_v1.ModelField):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.is_bytes_sequence_field(field)
|
||||
|
||||
return v2.is_bytes_sequence_field(field) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def is_scalar_field(field: ModelField) -> bool:
|
||||
if isinstance(field, may_v1.ModelField):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.is_scalar_field(field)
|
||||
|
||||
return v2.is_scalar_field(field) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def is_scalar_sequence_field(field: ModelField) -> bool:
|
||||
return v2.is_scalar_sequence_field(field) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def is_sequence_field(field: ModelField) -> bool:
|
||||
if isinstance(field, may_v1.ModelField):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.is_sequence_field(field)
|
||||
|
||||
return v2.is_sequence_field(field) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def serialize_sequence_value(*, field: ModelField, value: Any) -> Sequence[Any]:
|
||||
if isinstance(field, may_v1.ModelField):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.serialize_sequence_value(field=field, value=value)
|
||||
|
||||
return v2.serialize_sequence_value(field=field, value=value) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def get_compat_model_name_map(fields: list[ModelField]) -> ModelNameMap:
|
||||
v1_model_fields = [
|
||||
field for field in fields if isinstance(field, may_v1.ModelField)
|
||||
]
|
||||
if v1_model_fields:
|
||||
from fastapi._compat import v1
|
||||
|
||||
v1_flat_models = v1.get_flat_models_from_fields(
|
||||
v1_model_fields, # type: ignore[arg-type]
|
||||
known_models=set(),
|
||||
)
|
||||
all_flat_models = v1_flat_models
|
||||
else:
|
||||
all_flat_models = set()
|
||||
|
||||
v2_model_fields = [field for field in fields if isinstance(field, v2.ModelField)]
|
||||
v2_flat_models = v2.get_flat_models_from_fields(v2_model_fields, known_models=set())
|
||||
all_flat_models = all_flat_models.union(v2_flat_models) # type: ignore[arg-type]
|
||||
|
||||
model_name_map = v2.get_model_name_map(all_flat_models) # type: ignore[arg-type]
|
||||
return model_name_map
|
||||
|
||||
|
||||
def get_definitions(
|
||||
*,
|
||||
fields: list[ModelField],
|
||||
model_name_map: ModelNameMap,
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> tuple[
|
||||
dict[
|
||||
tuple[ModelField, Literal["validation", "serialization"]],
|
||||
may_v1.JsonSchemaValue,
|
||||
],
|
||||
dict[str, dict[str, Any]],
|
||||
]:
|
||||
if sys.version_info < (3, 14):
|
||||
v1_fields = [field for field in fields if isinstance(field, may_v1.ModelField)]
|
||||
v1_field_maps, v1_definitions = may_v1.get_definitions(
|
||||
fields=v1_fields, # type: ignore[arg-type]
|
||||
model_name_map=model_name_map,
|
||||
separate_input_output_schemas=separate_input_output_schemas,
|
||||
)
|
||||
|
||||
v2_fields = [field for field in fields if isinstance(field, v2.ModelField)]
|
||||
v2_field_maps, v2_definitions = v2.get_definitions(
|
||||
fields=v2_fields,
|
||||
model_name_map=model_name_map,
|
||||
separate_input_output_schemas=separate_input_output_schemas,
|
||||
)
|
||||
all_definitions = {**v1_definitions, **v2_definitions}
|
||||
all_field_maps = {**v1_field_maps, **v2_field_maps} # type: ignore[misc]
|
||||
return all_field_maps, all_definitions
|
||||
|
||||
# Pydantic v1 is not supported since Python 3.14
|
||||
else:
|
||||
v2_fields = [field for field in fields if isinstance(field, v2.ModelField)]
|
||||
v2_field_maps, v2_definitions = v2.get_definitions(
|
||||
fields=v2_fields,
|
||||
model_name_map=model_name_map,
|
||||
separate_input_output_schemas=separate_input_output_schemas,
|
||||
)
|
||||
return v2_field_maps, v2_definitions
|
||||
|
||||
|
||||
def get_schema_from_model_field(
|
||||
*,
|
||||
field: ModelField,
|
||||
model_name_map: ModelNameMap,
|
||||
field_mapping: dict[
|
||||
tuple[ModelField, Literal["validation", "serialization"]],
|
||||
may_v1.JsonSchemaValue,
|
||||
],
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
if isinstance(field, may_v1.ModelField):
|
||||
from fastapi._compat import v1
|
||||
|
||||
return v1.get_schema_from_model_field(
|
||||
field=field,
|
||||
model_name_map=model_name_map,
|
||||
field_mapping=field_mapping,
|
||||
separate_input_output_schemas=separate_input_output_schemas,
|
||||
)
|
||||
|
||||
return v2.get_schema_from_model_field(
|
||||
field=field, # type: ignore[arg-type]
|
||||
model_name_map=model_name_map,
|
||||
field_mapping=field_mapping, # type: ignore[arg-type]
|
||||
separate_input_output_schemas=separate_input_output_schemas,
|
||||
)
|
||||
|
||||
|
||||
def _is_model_field(value: Any) -> bool:
|
||||
if isinstance(value, may_v1.ModelField):
|
||||
return True
|
||||
|
||||
return isinstance(value, v2.ModelField)
|
||||
|
||||
|
||||
def _is_model_class(value: Any) -> bool:
|
||||
if lenient_issubclass(value, may_v1.BaseModel):
|
||||
return True
|
||||
|
||||
return lenient_issubclass(value, v2.BaseModel) # type: ignore[attr-defined]
|
||||
@@ -1,124 +0,0 @@
|
||||
import sys
|
||||
from collections.abc import Sequence
|
||||
from typing import Any, Literal, Union
|
||||
|
||||
from fastapi.types import ModelNameMap
|
||||
|
||||
if sys.version_info >= (3, 14):
|
||||
|
||||
class AnyUrl:
|
||||
pass
|
||||
|
||||
class BaseConfig:
|
||||
pass
|
||||
|
||||
class BaseModel:
|
||||
pass
|
||||
|
||||
class Color:
|
||||
pass
|
||||
|
||||
class CoreSchema:
|
||||
pass
|
||||
|
||||
class ErrorWrapper:
|
||||
pass
|
||||
|
||||
class FieldInfo:
|
||||
pass
|
||||
|
||||
class GetJsonSchemaHandler:
|
||||
pass
|
||||
|
||||
class JsonSchemaValue:
|
||||
pass
|
||||
|
||||
class ModelField:
|
||||
pass
|
||||
|
||||
class NameEmail:
|
||||
pass
|
||||
|
||||
class RequiredParam:
|
||||
pass
|
||||
|
||||
class SecretBytes:
|
||||
pass
|
||||
|
||||
class SecretStr:
|
||||
pass
|
||||
|
||||
class Undefined:
|
||||
pass
|
||||
|
||||
class UndefinedType:
|
||||
pass
|
||||
|
||||
class Url:
|
||||
pass
|
||||
|
||||
from .v2 import ValidationError, create_model
|
||||
|
||||
def get_definitions(
|
||||
*,
|
||||
fields: list[ModelField],
|
||||
model_name_map: ModelNameMap,
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> tuple[
|
||||
dict[
|
||||
tuple[ModelField, Literal["validation", "serialization"]], JsonSchemaValue
|
||||
],
|
||||
dict[str, dict[str, Any]],
|
||||
]:
|
||||
return {}, {} # pragma: no cover
|
||||
|
||||
|
||||
else:
|
||||
from .v1 import AnyUrl as AnyUrl
|
||||
from .v1 import BaseConfig as BaseConfig
|
||||
from .v1 import BaseModel as BaseModel
|
||||
from .v1 import Color as Color
|
||||
from .v1 import CoreSchema as CoreSchema
|
||||
from .v1 import ErrorWrapper as ErrorWrapper
|
||||
from .v1 import FieldInfo as FieldInfo
|
||||
from .v1 import GetJsonSchemaHandler as GetJsonSchemaHandler
|
||||
from .v1 import JsonSchemaValue as JsonSchemaValue
|
||||
from .v1 import ModelField as ModelField
|
||||
from .v1 import NameEmail as NameEmail
|
||||
from .v1 import RequiredParam as RequiredParam
|
||||
from .v1 import SecretBytes as SecretBytes
|
||||
from .v1 import SecretStr as SecretStr
|
||||
from .v1 import Undefined as Undefined
|
||||
from .v1 import UndefinedType as UndefinedType
|
||||
from .v1 import Url as Url
|
||||
from .v1 import ValidationError, create_model
|
||||
from .v1 import get_definitions as get_definitions
|
||||
|
||||
|
||||
RequestErrorModel: type[BaseModel] = create_model("Request")
|
||||
|
||||
|
||||
def _normalize_errors(errors: Sequence[Any]) -> list[dict[str, Any]]:
|
||||
use_errors: list[Any] = []
|
||||
for error in errors:
|
||||
if isinstance(error, ErrorWrapper):
|
||||
new_errors = ValidationError(
|
||||
errors=[error], model=RequestErrorModel
|
||||
).errors()
|
||||
use_errors.extend(new_errors)
|
||||
elif isinstance(error, list):
|
||||
use_errors.extend(_normalize_errors(error))
|
||||
else:
|
||||
use_errors.append(error)
|
||||
return use_errors
|
||||
|
||||
|
||||
def _regenerate_error_with_loc(
|
||||
*, errors: Sequence[Any], loc_prefix: tuple[Union[str, int], ...]
|
||||
) -> list[dict[str, Any]]:
|
||||
updated_loc_errors: list[Any] = [
|
||||
{**err, "loc": loc_prefix + err.get("loc", ())}
|
||||
for err in _normalize_errors(errors)
|
||||
]
|
||||
|
||||
return updated_loc_errors
|
||||
@@ -1,50 +0,0 @@
|
||||
from typing import (
|
||||
Any,
|
||||
Union,
|
||||
)
|
||||
|
||||
from fastapi.types import IncEx
|
||||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import Literal, Protocol
|
||||
|
||||
|
||||
class ModelField(Protocol):
|
||||
field_info: "FieldInfo"
|
||||
name: str
|
||||
mode: Literal["validation", "serialization"] = "validation"
|
||||
_version: Literal["v1", "v2"] = "v1"
|
||||
|
||||
@property
|
||||
def alias(self) -> str: ...
|
||||
|
||||
@property
|
||||
def required(self) -> bool: ...
|
||||
|
||||
@property
|
||||
def default(self) -> Any: ...
|
||||
|
||||
@property
|
||||
def type_(self) -> Any: ...
|
||||
|
||||
def get_default(self) -> Any: ...
|
||||
|
||||
def validate(
|
||||
self,
|
||||
value: Any,
|
||||
values: dict[str, Any] = {}, # noqa: B006
|
||||
*,
|
||||
loc: tuple[Union[int, str], ...] = (),
|
||||
) -> tuple[Any, Union[list[dict[str, Any]], None]]: ...
|
||||
|
||||
def serialize(
|
||||
self,
|
||||
value: Any,
|
||||
*,
|
||||
mode: Literal["json", "python"] = "json",
|
||||
include: Union[IncEx, None] = None,
|
||||
exclude: Union[IncEx, None] = None,
|
||||
by_alias: bool = True,
|
||||
exclude_unset: bool = False,
|
||||
exclude_defaults: bool = False,
|
||||
exclude_none: bool = False,
|
||||
) -> Any: ...
|
||||
@@ -1,6 +1,7 @@
|
||||
import sys
|
||||
import types
|
||||
import typing
|
||||
import warnings
|
||||
from collections import deque
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import is_dataclass
|
||||
@@ -10,7 +11,6 @@ from typing import (
|
||||
Union,
|
||||
)
|
||||
|
||||
from fastapi._compat import may_v1
|
||||
from fastapi.types import UnionType
|
||||
from pydantic import BaseModel
|
||||
from pydantic.version import VERSION as PYDANTIC_VERSION
|
||||
@@ -81,9 +81,7 @@ def value_is_sequence(value: Any) -> bool:
|
||||
|
||||
def _annotation_is_complex(annotation: Union[type[Any], None]) -> bool:
|
||||
return (
|
||||
lenient_issubclass(
|
||||
annotation, (BaseModel, may_v1.BaseModel, Mapping, UploadFile)
|
||||
)
|
||||
lenient_issubclass(annotation, (BaseModel, Mapping, UploadFile))
|
||||
or _annotation_is_sequence(annotation)
|
||||
or is_dataclass(annotation)
|
||||
)
|
||||
@@ -179,13 +177,27 @@ def is_uploadfile_sequence_annotation(annotation: Any) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def is_pydantic_v1_model_instance(obj: Any) -> bool:
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", UserWarning)
|
||||
from pydantic import v1
|
||||
return isinstance(obj, v1.BaseModel)
|
||||
|
||||
|
||||
def is_pydantic_v1_model_class(cls: Any) -> bool:
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", UserWarning)
|
||||
from pydantic import v1
|
||||
return lenient_issubclass(cls, v1.BaseModel)
|
||||
|
||||
|
||||
def annotation_is_pydantic_v1(annotation: Any) -> bool:
|
||||
if lenient_issubclass(annotation, may_v1.BaseModel):
|
||||
if is_pydantic_v1_model_class(annotation):
|
||||
return True
|
||||
origin = get_origin(annotation)
|
||||
if origin is Union or origin is UnionType:
|
||||
for arg in get_args(annotation):
|
||||
if lenient_issubclass(arg, may_v1.BaseModel):
|
||||
if is_pydantic_v1_model_class(arg):
|
||||
return True
|
||||
if field_annotation_is_sequence(annotation):
|
||||
for sub_annotation in get_args(annotation):
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
from collections.abc import Sequence
|
||||
from copy import copy
|
||||
from dataclasses import dataclass, is_dataclass
|
||||
from enum import Enum
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Union,
|
||||
)
|
||||
|
||||
from fastapi._compat import shared
|
||||
from fastapi.openapi.constants import REF_PREFIX as REF_PREFIX
|
||||
from fastapi.types import ModelNameMap
|
||||
from pydantic.v1 import BaseConfig as BaseConfig
|
||||
from pydantic.v1 import BaseModel as BaseModel
|
||||
from pydantic.v1 import ValidationError as ValidationError
|
||||
from pydantic.v1 import create_model as create_model
|
||||
from pydantic.v1.class_validators import Validator as Validator
|
||||
from pydantic.v1.color import Color as Color
|
||||
from pydantic.v1.error_wrappers import ErrorWrapper as ErrorWrapper
|
||||
from pydantic.v1.fields import (
|
||||
SHAPE_FROZENSET,
|
||||
SHAPE_LIST,
|
||||
SHAPE_SEQUENCE,
|
||||
SHAPE_SET,
|
||||
SHAPE_SINGLETON,
|
||||
SHAPE_TUPLE,
|
||||
SHAPE_TUPLE_ELLIPSIS,
|
||||
)
|
||||
from pydantic.v1.fields import FieldInfo as FieldInfo
|
||||
from pydantic.v1.fields import ModelField as ModelField
|
||||
from pydantic.v1.fields import Undefined as Undefined
|
||||
from pydantic.v1.fields import UndefinedType as UndefinedType
|
||||
from pydantic.v1.networks import AnyUrl as AnyUrl
|
||||
from pydantic.v1.networks import NameEmail as NameEmail
|
||||
from pydantic.v1.schema import TypeModelSet as TypeModelSet
|
||||
from pydantic.v1.schema import field_schema, model_process_schema
|
||||
from pydantic.v1.schema import (
|
||||
get_annotation_from_field_info as get_annotation_from_field_info,
|
||||
)
|
||||
from pydantic.v1.schema import (
|
||||
get_flat_models_from_field as get_flat_models_from_field,
|
||||
)
|
||||
from pydantic.v1.schema import (
|
||||
get_flat_models_from_fields as get_flat_models_from_fields,
|
||||
)
|
||||
from pydantic.v1.schema import get_model_name_map as get_model_name_map
|
||||
from pydantic.v1.types import SecretBytes as SecretBytes
|
||||
from pydantic.v1.types import SecretStr as SecretStr
|
||||
from pydantic.v1.typing import evaluate_forwardref as evaluate_forwardref
|
||||
from pydantic.v1.utils import lenient_issubclass as lenient_issubclass
|
||||
from pydantic.version import VERSION as PYDANTIC_VERSION
|
||||
from typing_extensions import Literal
|
||||
|
||||
PYDANTIC_VERSION_MINOR_TUPLE = tuple(int(x) for x in PYDANTIC_VERSION.split(".")[:2])
|
||||
PYDANTIC_V2 = PYDANTIC_VERSION_MINOR_TUPLE[0] == 2
|
||||
# Keeping old "Required" functionality from Pydantic V1, without
|
||||
# shadowing typing.Required.
|
||||
RequiredParam: Any = Ellipsis
|
||||
|
||||
|
||||
GetJsonSchemaHandler = Any
|
||||
JsonSchemaValue = dict[str, Any]
|
||||
CoreSchema = Any
|
||||
Url = AnyUrl
|
||||
|
||||
sequence_shapes = {
|
||||
SHAPE_LIST,
|
||||
SHAPE_SET,
|
||||
SHAPE_FROZENSET,
|
||||
SHAPE_TUPLE,
|
||||
SHAPE_SEQUENCE,
|
||||
SHAPE_TUPLE_ELLIPSIS,
|
||||
}
|
||||
sequence_shape_to_type = {
|
||||
SHAPE_LIST: list,
|
||||
SHAPE_SET: set,
|
||||
SHAPE_TUPLE: tuple,
|
||||
SHAPE_SEQUENCE: list,
|
||||
SHAPE_TUPLE_ELLIPSIS: list,
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class GenerateJsonSchema:
|
||||
ref_template: str
|
||||
|
||||
|
||||
class PydanticSchemaGenerationError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
RequestErrorModel: type[BaseModel] = create_model("Request")
|
||||
|
||||
|
||||
def with_info_plain_validator_function(
|
||||
function: Callable[..., Any],
|
||||
*,
|
||||
ref: Union[str, None] = None,
|
||||
metadata: Any = None,
|
||||
serialization: Any = None,
|
||||
) -> Any:
|
||||
return {}
|
||||
|
||||
|
||||
def get_model_definitions(
|
||||
*,
|
||||
flat_models: set[Union[type[BaseModel], type[Enum]]],
|
||||
model_name_map: dict[Union[type[BaseModel], type[Enum]], str],
|
||||
) -> dict[str, Any]:
|
||||
definitions: dict[str, dict[str, Any]] = {}
|
||||
for model in flat_models:
|
||||
m_schema, m_definitions, m_nested_models = model_process_schema(
|
||||
model, model_name_map=model_name_map, ref_prefix=REF_PREFIX
|
||||
)
|
||||
definitions.update(m_definitions)
|
||||
model_name = model_name_map[model]
|
||||
definitions[model_name] = m_schema
|
||||
for m_schema in definitions.values():
|
||||
if "description" in m_schema:
|
||||
m_schema["description"] = m_schema["description"].split("\f")[0]
|
||||
return definitions
|
||||
|
||||
|
||||
def is_pv1_scalar_field(field: ModelField) -> bool:
|
||||
from fastapi import params
|
||||
|
||||
field_info = field.field_info
|
||||
if not (
|
||||
field.shape == SHAPE_SINGLETON
|
||||
and not lenient_issubclass(field.type_, BaseModel)
|
||||
and not lenient_issubclass(field.type_, dict)
|
||||
and not shared.field_annotation_is_sequence(field.type_)
|
||||
and not is_dataclass(field.type_)
|
||||
and not isinstance(field_info, params.Body)
|
||||
):
|
||||
return False
|
||||
if field.sub_fields:
|
||||
if not all(is_pv1_scalar_field(f) for f in field.sub_fields):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _model_dump(
|
||||
model: BaseModel, mode: Literal["json", "python"] = "json", **kwargs: Any
|
||||
) -> Any:
|
||||
return model.dict(**kwargs)
|
||||
|
||||
|
||||
def _get_model_config(model: BaseModel) -> Any:
|
||||
return model.__config__
|
||||
|
||||
|
||||
def get_schema_from_model_field(
|
||||
*,
|
||||
field: ModelField,
|
||||
model_name_map: ModelNameMap,
|
||||
field_mapping: dict[
|
||||
tuple[ModelField, Literal["validation", "serialization"]], JsonSchemaValue
|
||||
],
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
return field_schema(
|
||||
field,
|
||||
model_name_map=model_name_map, # type: ignore[arg-type]
|
||||
ref_prefix=REF_PREFIX,
|
||||
)[0]
|
||||
|
||||
|
||||
# def get_compat_model_name_map(fields: List[ModelField]) -> ModelNameMap:
|
||||
# models = get_flat_models_from_fields(fields, known_models=set())
|
||||
# return get_model_name_map(models) # type: ignore[no-any-return]
|
||||
|
||||
|
||||
def get_definitions(
|
||||
*,
|
||||
fields: list[ModelField],
|
||||
model_name_map: ModelNameMap,
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> tuple[
|
||||
dict[tuple[ModelField, Literal["validation", "serialization"]], JsonSchemaValue],
|
||||
dict[str, dict[str, Any]],
|
||||
]:
|
||||
models = get_flat_models_from_fields(fields, known_models=set())
|
||||
return {}, get_model_definitions(flat_models=models, model_name_map=model_name_map) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def is_scalar_field(field: ModelField) -> bool:
|
||||
return is_pv1_scalar_field(field)
|
||||
|
||||
|
||||
def is_sequence_field(field: ModelField) -> bool:
|
||||
return field.shape in sequence_shapes or shared._annotation_is_sequence(field.type_)
|
||||
|
||||
|
||||
def is_bytes_field(field: ModelField) -> bool:
|
||||
return lenient_issubclass(field.type_, bytes)
|
||||
|
||||
|
||||
def is_bytes_sequence_field(field: ModelField) -> bool:
|
||||
return field.shape in sequence_shapes and lenient_issubclass(field.type_, bytes)
|
||||
|
||||
|
||||
def copy_field_info(*, field_info: FieldInfo, annotation: Any) -> FieldInfo:
|
||||
return copy(field_info)
|
||||
|
||||
|
||||
def serialize_sequence_value(*, field: ModelField, value: Any) -> Sequence[Any]:
|
||||
return sequence_shape_to_type[field.shape](value) # type: ignore[no-any-return]
|
||||
|
||||
|
||||
def create_body_model(
|
||||
*, fields: Sequence[ModelField], model_name: str
|
||||
) -> type[BaseModel]:
|
||||
BodyModel = create_model(model_name)
|
||||
for f in fields:
|
||||
BodyModel.__fields__[f.name] = f
|
||||
return BodyModel
|
||||
|
||||
|
||||
def get_model_fields(model: type[BaseModel]) -> list[ModelField]:
|
||||
return list(model.__fields__.values())
|
||||
@@ -4,6 +4,7 @@ from collections.abc import Sequence
|
||||
from copy import copy, deepcopy
|
||||
from dataclasses import dataclass, is_dataclass
|
||||
from enum import Enum
|
||||
from functools import lru_cache
|
||||
from typing import (
|
||||
Annotated,
|
||||
Any,
|
||||
@@ -11,7 +12,7 @@ from typing import (
|
||||
cast,
|
||||
)
|
||||
|
||||
from fastapi._compat import may_v1, shared
|
||||
from fastapi._compat import shared
|
||||
from fastapi.openapi.constants import REF_TEMPLATE
|
||||
from fastapi.types import IncEx, ModelNameMap, UnionType
|
||||
from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, create_model
|
||||
@@ -175,7 +176,7 @@ class ModelField:
|
||||
None,
|
||||
)
|
||||
except ValidationError as exc:
|
||||
return None, may_v1._regenerate_error_with_loc(
|
||||
return None, _regenerate_error_with_loc(
|
||||
errors=exc.errors(include_url=False), loc_prefix=loc
|
||||
)
|
||||
|
||||
@@ -210,22 +211,6 @@ class ModelField:
|
||||
return id(self)
|
||||
|
||||
|
||||
def get_annotation_from_field_info(
|
||||
annotation: Any, field_info: FieldInfo, field_name: str
|
||||
) -> Any:
|
||||
return annotation
|
||||
|
||||
|
||||
def _model_dump(
|
||||
model: BaseModel, mode: Literal["json", "python"] = "json", **kwargs: Any
|
||||
) -> Any:
|
||||
return model.model_dump(mode=mode, **kwargs)
|
||||
|
||||
|
||||
def _get_model_config(model: BaseModel) -> Any:
|
||||
return model.model_config
|
||||
|
||||
|
||||
def _has_computed_fields(field: ModelField) -> bool:
|
||||
computed_fields = field._type_adapter.core_schema.get("schema", {}).get(
|
||||
"computed_fields", []
|
||||
@@ -490,6 +475,11 @@ def get_model_fields(model: type[BaseModel]) -> list[ModelField]:
|
||||
return model_fields
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_cached_model_fields(model: type[BaseModel]) -> list[ModelField]:
|
||||
return get_model_fields(model) # type: ignore[return-value]
|
||||
|
||||
|
||||
# Duplicate of several schema functions from Pydantic v1 to make them compatible with
|
||||
# Pydantic v2 and allow mixing the models
|
||||
|
||||
@@ -503,22 +493,23 @@ def normalize_name(name: str) -> str:
|
||||
|
||||
def get_model_name_map(unique_models: TypeModelSet) -> dict[TypeModelOrEnum, str]:
|
||||
name_model_map = {}
|
||||
conflicting_names: set[str] = set()
|
||||
for model in unique_models:
|
||||
model_name = normalize_name(model.__name__)
|
||||
if model_name in conflicting_names:
|
||||
model_name = get_long_model_name(model)
|
||||
name_model_map[model_name] = model
|
||||
elif model_name in name_model_map:
|
||||
conflicting_names.add(model_name)
|
||||
conflicting_model = name_model_map.pop(model_name)
|
||||
name_model_map[get_long_model_name(conflicting_model)] = conflicting_model
|
||||
name_model_map[get_long_model_name(model)] = model
|
||||
else:
|
||||
name_model_map[model_name] = model
|
||||
name_model_map[model_name] = model
|
||||
return {v: k for k, v in name_model_map.items()}
|
||||
|
||||
|
||||
def get_compat_model_name_map(fields: list[ModelField]) -> ModelNameMap:
|
||||
all_flat_models = set()
|
||||
|
||||
v2_model_fields = [field for field in fields if isinstance(field, ModelField)]
|
||||
v2_flat_models = get_flat_models_from_fields(v2_model_fields, known_models=set())
|
||||
all_flat_models = all_flat_models.union(v2_flat_models) # type: ignore[arg-type]
|
||||
|
||||
model_name_map = get_model_name_map(all_flat_models) # type: ignore[arg-type]
|
||||
return model_name_map
|
||||
|
||||
|
||||
def get_flat_models_from_model(
|
||||
model: type["BaseModel"], known_models: Union[TypeModelSet, None] = None
|
||||
) -> TypeModelSet:
|
||||
@@ -567,5 +558,11 @@ def get_flat_models_from_fields(
|
||||
return known_models
|
||||
|
||||
|
||||
def get_long_model_name(model: TypeModelOrEnum) -> str:
|
||||
return f"{model.__module__}__{model.__qualname__}".replace(".", "__")
|
||||
def _regenerate_error_with_loc(
|
||||
*, errors: Sequence[Any], loc_prefix: tuple[Union[str, int], ...]
|
||||
) -> list[dict[str, Any]]:
|
||||
updated_loc_errors: list[Any] = [
|
||||
{**err, "loc": loc_prefix + err.get("loc", ())} for err in errors
|
||||
]
|
||||
|
||||
return updated_loc_errors
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import (
|
||||
Annotated,
|
||||
Any,
|
||||
@@ -9,11 +10,7 @@ from typing import (
|
||||
)
|
||||
|
||||
from annotated_doc import Doc
|
||||
from fastapi._compat import (
|
||||
CoreSchema,
|
||||
GetJsonSchemaHandler,
|
||||
JsonSchemaValue,
|
||||
)
|
||||
from pydantic import GetJsonSchemaHandler
|
||||
from starlette.datastructures import URL as URL # noqa: F401
|
||||
from starlette.datastructures import Address as Address # noqa: F401
|
||||
from starlette.datastructures import FormData as FormData # noqa: F401
|
||||
@@ -142,14 +139,14 @@ class UploadFile(StarletteUploadFile):
|
||||
|
||||
@classmethod
|
||||
def __get_pydantic_json_schema__(
|
||||
cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
|
||||
) -> JsonSchemaValue:
|
||||
cls, core_schema: Mapping[str, Any], handler: GetJsonSchemaHandler
|
||||
) -> dict[str, Any]:
|
||||
return {"type": "string", "format": "binary"}
|
||||
|
||||
@classmethod
|
||||
def __get_pydantic_core_schema__(
|
||||
cls, source: type[Any], handler: Callable[[Any], CoreSchema]
|
||||
) -> CoreSchema:
|
||||
cls, source: type[Any], handler: Callable[[Any], Mapping[str, Any]]
|
||||
) -> Mapping[str, Any]:
|
||||
from ._compat.v2 import with_info_plain_validator_function
|
||||
|
||||
return with_info_plain_validator_function(cls._validate)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import dataclasses
|
||||
import inspect
|
||||
import sys
|
||||
import warnings
|
||||
from collections.abc import Coroutine, Mapping, Sequence
|
||||
from contextlib import AsyncExitStack, contextmanager
|
||||
from copy import copy, deepcopy
|
||||
@@ -22,13 +21,11 @@ from fastapi._compat import (
|
||||
ModelField,
|
||||
RequiredParam,
|
||||
Undefined,
|
||||
_is_error_wrapper,
|
||||
_is_model_class,
|
||||
_regenerate_error_with_loc,
|
||||
copy_field_info,
|
||||
create_body_model,
|
||||
evaluate_forwardref,
|
||||
field_annotation_is_scalar,
|
||||
get_annotation_from_field_info,
|
||||
get_cached_model_fields,
|
||||
get_missing_field_error,
|
||||
is_bytes_field,
|
||||
@@ -39,19 +36,17 @@ from fastapi._compat import (
|
||||
is_uploadfile_or_nonable_uploadfile_annotation,
|
||||
is_uploadfile_sequence_annotation,
|
||||
lenient_issubclass,
|
||||
may_v1,
|
||||
sequence_types,
|
||||
serialize_sequence_value,
|
||||
value_is_sequence,
|
||||
)
|
||||
from fastapi._compat.shared import annotation_is_pydantic_v1
|
||||
from fastapi.background import BackgroundTasks
|
||||
from fastapi.concurrency import (
|
||||
asynccontextmanager,
|
||||
contextmanager_in_threadpool,
|
||||
)
|
||||
from fastapi.dependencies.models import Dependant
|
||||
from fastapi.exceptions import DependencyScopeError, FastAPIDeprecationWarning
|
||||
from fastapi.exceptions import DependencyScopeError
|
||||
from fastapi.logger import logger
|
||||
from fastapi.security.oauth2 import SecurityScopes
|
||||
from fastapi.types import DependencyCacheKey
|
||||
@@ -72,8 +67,6 @@ from starlette.responses import Response
|
||||
from starlette.websockets import WebSocket
|
||||
from typing_extensions import Literal, get_args, get_origin
|
||||
|
||||
from .. import temp_pydantic_v1_params
|
||||
|
||||
multipart_not_installed_error = (
|
||||
'Form data requires "python-multipart" to be installed. \n'
|
||||
'You can install "python-multipart" with: \n\n'
|
||||
@@ -189,7 +182,7 @@ def _get_flat_fields_from_params(fields: list[ModelField]) -> list[ModelField]:
|
||||
if not fields:
|
||||
return fields
|
||||
first_field = fields[0]
|
||||
if len(fields) == 1 and _is_model_class(first_field.type_):
|
||||
if len(fields) == 1 and lenient_issubclass(first_field.type_, BaseModel):
|
||||
fields_to_extract = get_cached_model_fields(first_field.type_)
|
||||
return fields_to_extract
|
||||
return fields
|
||||
@@ -323,16 +316,7 @@ def get_dependant(
|
||||
)
|
||||
continue
|
||||
assert param_details.field is not None
|
||||
if isinstance(param_details.field, may_v1.ModelField):
|
||||
warnings.warn(
|
||||
"pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
|
||||
f" Please update the param {param_name}: {param_details.type_annotation!r}.",
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=5,
|
||||
)
|
||||
if isinstance(
|
||||
param_details.field.field_info, (params.Body, temp_pydantic_v1_params.Body)
|
||||
):
|
||||
if isinstance(param_details.field.field_info, params.Body):
|
||||
dependant.body_params.append(param_details.field)
|
||||
else:
|
||||
add_param_to_fields(field=param_details.field, dependant=dependant)
|
||||
@@ -391,7 +375,7 @@ def analyze_param(
|
||||
fastapi_annotations = [
|
||||
arg
|
||||
for arg in annotated_args[1:]
|
||||
if isinstance(arg, (FieldInfo, may_v1.FieldInfo, params.Depends))
|
||||
if isinstance(arg, (FieldInfo, params.Depends))
|
||||
]
|
||||
fastapi_specific_annotations = [
|
||||
arg
|
||||
@@ -400,30 +384,27 @@ def analyze_param(
|
||||
arg,
|
||||
(
|
||||
params.Param,
|
||||
temp_pydantic_v1_params.Param,
|
||||
params.Body,
|
||||
temp_pydantic_v1_params.Body,
|
||||
params.Depends,
|
||||
),
|
||||
)
|
||||
]
|
||||
if fastapi_specific_annotations:
|
||||
fastapi_annotation: Union[
|
||||
FieldInfo, may_v1.FieldInfo, params.Depends, None
|
||||
] = fastapi_specific_annotations[-1]
|
||||
fastapi_annotation: Union[FieldInfo, params.Depends, None] = (
|
||||
fastapi_specific_annotations[-1]
|
||||
)
|
||||
else:
|
||||
fastapi_annotation = None
|
||||
# Set default for Annotated FieldInfo
|
||||
if isinstance(fastapi_annotation, (FieldInfo, may_v1.FieldInfo)):
|
||||
if isinstance(fastapi_annotation, FieldInfo):
|
||||
# Copy `field_info` because we mutate `field_info.default` below.
|
||||
field_info = copy_field_info(
|
||||
field_info=fastapi_annotation, # type: ignore[arg-type]
|
||||
annotation=use_annotation,
|
||||
)
|
||||
assert field_info.default in {
|
||||
Undefined,
|
||||
may_v1.Undefined,
|
||||
} or field_info.default in {RequiredParam, may_v1.RequiredParam}, (
|
||||
assert (
|
||||
field_info.default == Undefined or field_info.default == RequiredParam
|
||||
), (
|
||||
f"`{field_info.__class__.__name__}` default value cannot be set in"
|
||||
f" `Annotated` for {param_name!r}. Set the default value with `=` instead."
|
||||
)
|
||||
@@ -447,7 +428,7 @@ def analyze_param(
|
||||
)
|
||||
depends = value
|
||||
# Get FieldInfo from default value
|
||||
elif isinstance(value, (FieldInfo, may_v1.FieldInfo)):
|
||||
elif isinstance(value, FieldInfo):
|
||||
assert field_info is None, (
|
||||
"Cannot specify FastAPI annotations in `Annotated` and default value"
|
||||
f" together for {param_name!r}"
|
||||
@@ -491,14 +472,7 @@ def analyze_param(
|
||||
) or is_uploadfile_sequence_annotation(type_annotation):
|
||||
field_info = params.File(annotation=use_annotation, default=default_value)
|
||||
elif not field_annotation_is_scalar(annotation=type_annotation):
|
||||
if annotation_is_pydantic_v1(use_annotation):
|
||||
field_info = temp_pydantic_v1_params.Body( # type: ignore[assignment]
|
||||
annotation=use_annotation, default=default_value
|
||||
)
|
||||
else:
|
||||
field_info = params.Body(
|
||||
annotation=use_annotation, default=default_value
|
||||
)
|
||||
field_info = params.Body(annotation=use_annotation, default=default_value)
|
||||
else:
|
||||
field_info = params.Query(annotation=use_annotation, default=default_value)
|
||||
|
||||
@@ -507,23 +481,17 @@ def analyze_param(
|
||||
if field_info is not None:
|
||||
# Handle field_info.in_
|
||||
if is_path_param:
|
||||
assert isinstance(
|
||||
field_info, (params.Path, temp_pydantic_v1_params.Path)
|
||||
), (
|
||||
assert isinstance(field_info, params.Path), (
|
||||
f"Cannot use `{field_info.__class__.__name__}` for path param"
|
||||
f" {param_name!r}"
|
||||
)
|
||||
elif (
|
||||
isinstance(field_info, (params.Param, temp_pydantic_v1_params.Param))
|
||||
isinstance(field_info, params.Param)
|
||||
and getattr(field_info, "in_", None) is None
|
||||
):
|
||||
field_info.in_ = params.ParamTypes.query
|
||||
use_annotation_from_field_info = get_annotation_from_field_info(
|
||||
use_annotation,
|
||||
field_info,
|
||||
param_name,
|
||||
)
|
||||
if isinstance(field_info, (params.Form, temp_pydantic_v1_params.Form)):
|
||||
use_annotation_from_field_info = use_annotation
|
||||
if isinstance(field_info, params.Form):
|
||||
ensure_multipart_is_installed()
|
||||
if not field_info.alias and getattr(field_info, "convert_underscores", None):
|
||||
alias = param_name.replace("_", "-")
|
||||
@@ -535,20 +503,19 @@ def analyze_param(
|
||||
type_=use_annotation_from_field_info,
|
||||
default=field_info.default,
|
||||
alias=alias,
|
||||
required=field_info.default
|
||||
in (RequiredParam, may_v1.RequiredParam, Undefined),
|
||||
required=field_info.default in (RequiredParam, Undefined),
|
||||
field_info=field_info,
|
||||
)
|
||||
if is_path_param:
|
||||
assert is_scalar_field(field=field), (
|
||||
"Path params must be of one of the supported types"
|
||||
)
|
||||
elif isinstance(field_info, (params.Query, temp_pydantic_v1_params.Query)):
|
||||
elif isinstance(field_info, params.Query):
|
||||
assert (
|
||||
is_scalar_field(field)
|
||||
or is_scalar_sequence_field(field)
|
||||
or (
|
||||
_is_model_class(field.type_)
|
||||
lenient_issubclass(field.type_, BaseModel)
|
||||
# For Pydantic v1
|
||||
and getattr(field, "shape", 1) == 1
|
||||
)
|
||||
@@ -742,10 +709,8 @@ def _validate_value_with_model_field(
|
||||
else:
|
||||
return deepcopy(field.default), []
|
||||
v_, errors_ = field.validate(value, values, loc=loc)
|
||||
if _is_error_wrapper(errors_): # type: ignore[arg-type]
|
||||
return None, [errors_]
|
||||
elif isinstance(errors_, list):
|
||||
new_errors = may_v1._regenerate_error_with_loc(errors=errors_, loc_prefix=())
|
||||
if isinstance(errors_, list):
|
||||
new_errors = _regenerate_error_with_loc(errors=errors_, loc_prefix=())
|
||||
return None, new_errors
|
||||
else:
|
||||
return v_, []
|
||||
@@ -762,7 +727,7 @@ def _get_multidict_value(
|
||||
if (
|
||||
value is None
|
||||
or (
|
||||
isinstance(field.field_info, (params.Form, temp_pydantic_v1_params.Form))
|
||||
isinstance(field.field_info, params.Form)
|
||||
and isinstance(value, str) # For type checks
|
||||
and value == ""
|
||||
)
|
||||
@@ -832,7 +797,7 @@ def request_params_to_args(
|
||||
|
||||
if single_not_embedded_field:
|
||||
field_info = first_field.field_info
|
||||
assert isinstance(field_info, (params.Param, temp_pydantic_v1_params.Param)), (
|
||||
assert isinstance(field_info, params.Param), (
|
||||
"Params must be subclasses of Param"
|
||||
)
|
||||
loc: tuple[str, ...] = (field_info.in_.value,)
|
||||
@@ -844,7 +809,7 @@ def request_params_to_args(
|
||||
for field in fields:
|
||||
value = _get_multidict_value(field, received_params)
|
||||
field_info = field.field_info
|
||||
assert isinstance(field_info, (params.Param, temp_pydantic_v1_params.Param)), (
|
||||
assert isinstance(field_info, params.Param), (
|
||||
"Params must be subclasses of Param"
|
||||
)
|
||||
loc = (field_info.in_.value, get_validation_alias(field))
|
||||
@@ -871,7 +836,7 @@ def is_union_of_base_models(field_type: Any) -> bool:
|
||||
union_args = get_args(field_type)
|
||||
|
||||
for arg in union_args:
|
||||
if not _is_model_class(arg):
|
||||
if not lenient_issubclass(arg, BaseModel):
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -893,8 +858,8 @@ def _should_embed_body_fields(fields: list[ModelField]) -> bool:
|
||||
# If it's a Form (or File) field, it has to be a BaseModel (or a union of BaseModels) to be top level
|
||||
# otherwise it has to be embedded, so that the key value pair can be extracted
|
||||
if (
|
||||
isinstance(first_field.field_info, (params.Form, temp_pydantic_v1_params.Form))
|
||||
and not _is_model_class(first_field.type_)
|
||||
isinstance(first_field.field_info, params.Form)
|
||||
and not lenient_issubclass(first_field.type_, BaseModel)
|
||||
and not is_union_of_base_models(first_field.type_)
|
||||
):
|
||||
return True
|
||||
@@ -911,14 +876,14 @@ async def _extract_form_body(
|
||||
value = _get_multidict_value(field, received_body)
|
||||
field_info = field.field_info
|
||||
if (
|
||||
isinstance(field_info, (params.File, temp_pydantic_v1_params.File))
|
||||
isinstance(field_info, params.File)
|
||||
and is_bytes_field(field)
|
||||
and isinstance(value, UploadFile)
|
||||
):
|
||||
value = await value.read()
|
||||
elif (
|
||||
is_bytes_sequence_field(field)
|
||||
and isinstance(field_info, (params.File, temp_pydantic_v1_params.File))
|
||||
and isinstance(field_info, params.File)
|
||||
and value_is_sequence(value)
|
||||
):
|
||||
# For types
|
||||
@@ -964,7 +929,7 @@ async def request_body_to_args(
|
||||
|
||||
if (
|
||||
single_not_embedded_field
|
||||
and _is_model_class(first_field.type_)
|
||||
and lenient_issubclass(first_field.type_, BaseModel)
|
||||
and isinstance(received_body, FormData)
|
||||
):
|
||||
fields_to_extract = get_cached_model_fields(first_field.type_)
|
||||
@@ -1029,28 +994,15 @@ def get_body_field(
|
||||
BodyFieldInfo_kwargs["default"] = None
|
||||
if any(isinstance(f.field_info, params.File) for f in flat_dependant.body_params):
|
||||
BodyFieldInfo: type[params.Body] = params.File
|
||||
elif any(
|
||||
isinstance(f.field_info, temp_pydantic_v1_params.File)
|
||||
for f in flat_dependant.body_params
|
||||
):
|
||||
BodyFieldInfo: type[temp_pydantic_v1_params.Body] = temp_pydantic_v1_params.File # type: ignore[no-redef]
|
||||
elif any(isinstance(f.field_info, params.Form) for f in flat_dependant.body_params):
|
||||
BodyFieldInfo = params.Form
|
||||
elif any(
|
||||
isinstance(f.field_info, temp_pydantic_v1_params.Form)
|
||||
for f in flat_dependant.body_params
|
||||
):
|
||||
BodyFieldInfo = temp_pydantic_v1_params.Form # type: ignore[assignment]
|
||||
else:
|
||||
if annotation_is_pydantic_v1(BodyModel):
|
||||
BodyFieldInfo = temp_pydantic_v1_params.Body # type: ignore[assignment]
|
||||
else:
|
||||
BodyFieldInfo = params.Body
|
||||
BodyFieldInfo = params.Body
|
||||
|
||||
body_param_media_types = [
|
||||
f.field_info.media_type
|
||||
for f in flat_dependant.body_params
|
||||
if isinstance(f.field_info, (params.Body, temp_pydantic_v1_params.Body))
|
||||
if isinstance(f.field_info, params.Body)
|
||||
]
|
||||
if len(set(body_param_media_types)) == 1:
|
||||
BodyFieldInfo_kwargs["media_type"] = body_param_media_types[0]
|
||||
|
||||
@@ -18,14 +18,18 @@ from typing import Annotated, Any, Callable, Optional, Union
|
||||
from uuid import UUID
|
||||
|
||||
from annotated_doc import Doc
|
||||
from fastapi._compat import may_v1
|
||||
from fastapi.exceptions import PydanticV1NotSupportedError
|
||||
from fastapi.types import IncEx
|
||||
from pydantic import BaseModel
|
||||
from pydantic.color import Color
|
||||
from pydantic.networks import AnyUrl, NameEmail
|
||||
from pydantic.types import SecretBytes, SecretStr
|
||||
from pydantic_core import PydanticUndefinedType
|
||||
|
||||
from ._compat import Url, _is_undefined, _model_dump
|
||||
from ._compat import (
|
||||
Url,
|
||||
is_pydantic_v1_model_instance,
|
||||
)
|
||||
|
||||
|
||||
# Taken from Pydantic v1 as is
|
||||
@@ -63,7 +67,6 @@ def decimal_encoder(dec_value: Decimal) -> Union[int, float]:
|
||||
ENCODERS_BY_TYPE: dict[type[Any], Callable[[Any], Any]] = {
|
||||
bytes: lambda o: o.decode(),
|
||||
Color: str,
|
||||
may_v1.Color: str,
|
||||
datetime.date: isoformat,
|
||||
datetime.datetime: isoformat,
|
||||
datetime.time: isoformat,
|
||||
@@ -80,19 +83,14 @@ ENCODERS_BY_TYPE: dict[type[Any], Callable[[Any], Any]] = {
|
||||
IPv6Interface: str,
|
||||
IPv6Network: str,
|
||||
NameEmail: str,
|
||||
may_v1.NameEmail: str,
|
||||
Path: str,
|
||||
Pattern: lambda o: o.pattern,
|
||||
SecretBytes: str,
|
||||
may_v1.SecretBytes: str,
|
||||
SecretStr: str,
|
||||
may_v1.SecretStr: str,
|
||||
set: list,
|
||||
UUID: str,
|
||||
Url: str,
|
||||
may_v1.Url: str,
|
||||
AnyUrl: str,
|
||||
may_v1.AnyUrl: str,
|
||||
}
|
||||
|
||||
|
||||
@@ -224,15 +222,8 @@ def jsonable_encoder(
|
||||
include = set(include)
|
||||
if exclude is not None and not isinstance(exclude, (set, dict)):
|
||||
exclude = set(exclude)
|
||||
if isinstance(obj, (BaseModel, may_v1.BaseModel)):
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
encoders: dict[Any, Any] = {}
|
||||
if isinstance(obj, may_v1.BaseModel):
|
||||
encoders = getattr(obj.__config__, "json_encoders", {})
|
||||
if custom_encoder:
|
||||
encoders = {**encoders, **custom_encoder}
|
||||
obj_dict = _model_dump(
|
||||
obj, # type: ignore[arg-type]
|
||||
if isinstance(obj, BaseModel):
|
||||
obj_dict = obj.model_dump(
|
||||
mode="json",
|
||||
include=include,
|
||||
exclude=exclude,
|
||||
@@ -241,14 +232,10 @@ def jsonable_encoder(
|
||||
exclude_none=exclude_none,
|
||||
exclude_defaults=exclude_defaults,
|
||||
)
|
||||
if "__root__" in obj_dict:
|
||||
obj_dict = obj_dict["__root__"]
|
||||
return jsonable_encoder(
|
||||
obj_dict,
|
||||
exclude_none=exclude_none,
|
||||
exclude_defaults=exclude_defaults,
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
custom_encoder=encoders,
|
||||
sqlalchemy_safe=sqlalchemy_safe,
|
||||
)
|
||||
if dataclasses.is_dataclass(obj):
|
||||
@@ -271,7 +258,7 @@ def jsonable_encoder(
|
||||
return str(obj)
|
||||
if isinstance(obj, (str, int, float, type(None))):
|
||||
return obj
|
||||
if _is_undefined(obj):
|
||||
if isinstance(obj, PydanticUndefinedType):
|
||||
return None
|
||||
if isinstance(obj, dict):
|
||||
encoded_dict = {}
|
||||
@@ -331,7 +318,11 @@ def jsonable_encoder(
|
||||
for encoder, classes_tuple in encoders_by_class_tuples.items():
|
||||
if isinstance(obj, classes_tuple):
|
||||
return encoder(obj)
|
||||
|
||||
if is_pydantic_v1_model_instance(obj):
|
||||
raise PydanticV1NotSupportedError(
|
||||
"pydantic.v1 models are no longer supported by FastAPI."
|
||||
f" Please update the model {obj!r}."
|
||||
)
|
||||
try:
|
||||
data = dict(obj)
|
||||
except Exception as e:
|
||||
|
||||
@@ -233,6 +233,12 @@ class ResponseValidationError(ValidationException):
|
||||
self.body = body
|
||||
|
||||
|
||||
class PydanticV1NotSupportedError(FastAPIError):
|
||||
"""
|
||||
A pydantic.v1 model is used, which is no longer supported.
|
||||
"""
|
||||
|
||||
|
||||
class FastAPIDeprecationWarning(UserWarning):
|
||||
"""
|
||||
A custom deprecation warning as DeprecationWarning is ignored
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
from collections.abc import Iterable
|
||||
from collections.abc import Iterable, Mapping
|
||||
from enum import Enum
|
||||
from typing import Annotated, Any, Callable, Optional, Union
|
||||
|
||||
from fastapi._compat import (
|
||||
CoreSchema,
|
||||
GetJsonSchemaHandler,
|
||||
JsonSchemaValue,
|
||||
with_info_plain_validator_function,
|
||||
)
|
||||
from fastapi._compat import with_info_plain_validator_function
|
||||
from fastapi.logger import logger
|
||||
from pydantic import AnyUrl, BaseModel, Field
|
||||
from pydantic import (
|
||||
AnyUrl,
|
||||
BaseModel,
|
||||
Field,
|
||||
GetJsonSchemaHandler,
|
||||
)
|
||||
from typing_extensions import Literal, TypedDict
|
||||
from typing_extensions import deprecated as typing_deprecated
|
||||
|
||||
@@ -43,14 +43,14 @@ except ImportError: # pragma: no cover
|
||||
|
||||
@classmethod
|
||||
def __get_pydantic_json_schema__(
|
||||
cls, core_schema: CoreSchema, handler: GetJsonSchemaHandler
|
||||
) -> JsonSchemaValue:
|
||||
cls, core_schema: Mapping[str, Any], handler: GetJsonSchemaHandler
|
||||
) -> dict[str, Any]:
|
||||
return {"type": "string", "format": "email"}
|
||||
|
||||
@classmethod
|
||||
def __get_pydantic_core_schema__(
|
||||
cls, source: type[Any], handler: Callable[[Any], CoreSchema]
|
||||
) -> CoreSchema:
|
||||
cls, source: type[Any], handler: Callable[[Any], Mapping[str, Any]]
|
||||
) -> Mapping[str, Any]:
|
||||
return with_info_plain_validator_function(cls._validate)
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from typing import Any, Optional, Union, cast
|
||||
|
||||
from fastapi import routing
|
||||
from fastapi._compat import (
|
||||
JsonSchemaValue,
|
||||
ModelField,
|
||||
Undefined,
|
||||
get_compat_model_name_map,
|
||||
@@ -39,8 +38,6 @@ from starlette.responses import JSONResponse
|
||||
from starlette.routing import BaseRoute
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .._compat import _is_model_field
|
||||
|
||||
validation_error_definition = {
|
||||
"title": "ValidationError",
|
||||
"type": "object",
|
||||
@@ -109,7 +106,7 @@ def _get_openapi_operation_parameters(
|
||||
dependant: Dependant,
|
||||
model_name_map: ModelNameMap,
|
||||
field_mapping: dict[
|
||||
tuple[ModelField, Literal["validation", "serialization"]], JsonSchemaValue
|
||||
tuple[ModelField, Literal["validation", "serialization"]], dict[str, Any]
|
||||
],
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> list[dict[str, Any]]:
|
||||
@@ -182,13 +179,13 @@ def get_openapi_operation_request_body(
|
||||
body_field: Optional[ModelField],
|
||||
model_name_map: ModelNameMap,
|
||||
field_mapping: dict[
|
||||
tuple[ModelField, Literal["validation", "serialization"]], JsonSchemaValue
|
||||
tuple[ModelField, Literal["validation", "serialization"]], dict[str, Any]
|
||||
],
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> Optional[dict[str, Any]]:
|
||||
if not body_field:
|
||||
return None
|
||||
assert _is_model_field(body_field)
|
||||
assert isinstance(body_field, ModelField)
|
||||
body_schema = get_schema_from_model_field(
|
||||
field=body_field,
|
||||
model_name_map=model_name_map,
|
||||
@@ -265,7 +262,7 @@ def get_openapi_path(
|
||||
operation_ids: set[str],
|
||||
model_name_map: ModelNameMap,
|
||||
field_mapping: dict[
|
||||
tuple[ModelField, Literal["validation", "serialization"]], JsonSchemaValue
|
||||
tuple[ModelField, Literal["validation", "serialization"]], dict[str, Any]
|
||||
],
|
||||
separate_input_output_schemas: bool = True,
|
||||
) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]:
|
||||
@@ -457,7 +454,7 @@ def get_fields_from_routes(
|
||||
route, routing.APIRoute
|
||||
):
|
||||
if route.body_field:
|
||||
assert _is_model_field(route.body_field), (
|
||||
assert isinstance(route.body_field, ModelField), (
|
||||
"A request body must be a Pydantic Field"
|
||||
)
|
||||
body_fields_from_routes.append(route.body_field)
|
||||
|
||||
@@ -5,6 +5,7 @@ from annotated_doc import Doc
|
||||
from fastapi import params
|
||||
from fastapi._compat import Undefined
|
||||
from fastapi.openapi.models import Example
|
||||
from pydantic import AliasChoices, AliasPath
|
||||
from typing_extensions import Literal, deprecated
|
||||
|
||||
_Unset: Any = Undefined
|
||||
@@ -54,10 +55,8 @@ def Path( # noqa: N802
|
||||
"""
|
||||
),
|
||||
] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Annotated[
|
||||
Union[str, None],
|
||||
Union[str, AliasPath, AliasChoices, None],
|
||||
Doc(
|
||||
"""
|
||||
'Whitelist' validation step. The parameter field will be the single one
|
||||
@@ -379,10 +378,8 @@ def Query( # noqa: N802
|
||||
"""
|
||||
),
|
||||
] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Annotated[
|
||||
Union[str, None],
|
||||
Union[str, AliasPath, AliasChoices, None],
|
||||
Doc(
|
||||
"""
|
||||
'Whitelist' validation step. The parameter field will be the single one
|
||||
@@ -683,10 +680,8 @@ def Header( # noqa: N802
|
||||
"""
|
||||
),
|
||||
] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Annotated[
|
||||
Union[str, None],
|
||||
Union[str, AliasPath, AliasChoices, None],
|
||||
Doc(
|
||||
"""
|
||||
'Whitelist' validation step. The parameter field will be the single one
|
||||
@@ -999,10 +994,8 @@ def Cookie( # noqa: N802
|
||||
"""
|
||||
),
|
||||
] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Annotated[
|
||||
Union[str, None],
|
||||
Union[str, AliasPath, AliasChoices, None],
|
||||
Doc(
|
||||
"""
|
||||
'Whitelist' validation step. The parameter field will be the single one
|
||||
@@ -1326,10 +1319,8 @@ def Body( # noqa: N802
|
||||
"""
|
||||
),
|
||||
] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Annotated[
|
||||
Union[str, None],
|
||||
Union[str, AliasPath, AliasChoices, None],
|
||||
Doc(
|
||||
"""
|
||||
'Whitelist' validation step. The parameter field will be the single one
|
||||
@@ -1641,10 +1632,8 @@ def Form( # noqa: N802
|
||||
"""
|
||||
),
|
||||
] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Annotated[
|
||||
Union[str, None],
|
||||
Union[str, AliasPath, AliasChoices, None],
|
||||
Doc(
|
||||
"""
|
||||
'Whitelist' validation step. The parameter field will be the single one
|
||||
@@ -1955,10 +1944,8 @@ def File( # noqa: N802
|
||||
"""
|
||||
),
|
||||
] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Annotated[
|
||||
Union[str, None],
|
||||
Union[str, AliasPath, AliasChoices, None],
|
||||
Doc(
|
||||
"""
|
||||
'Whitelist' validation step. The parameter field will be the single one
|
||||
|
||||
@@ -6,6 +6,7 @@ from typing import Annotated, Any, Callable, Optional, Union
|
||||
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.openapi.models import Example
|
||||
from pydantic import AliasChoices, AliasPath
|
||||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import Literal, deprecated
|
||||
|
||||
@@ -34,9 +35,7 @@ class Param(FieldInfo): # type: ignore[misc]
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
@@ -147,9 +146,7 @@ class Path(Param): # type: ignore[misc]
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
@@ -233,9 +230,7 @@ class Query(Param): # type: ignore[misc]
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
@@ -317,9 +312,7 @@ class Header(Param): # type: ignore[misc]
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
convert_underscores: bool = True,
|
||||
title: Optional[str] = None,
|
||||
@@ -403,9 +396,7 @@ class Cookie(Param): # type: ignore[misc]
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
@@ -487,9 +478,7 @@ class Body(FieldInfo): # type: ignore[misc]
|
||||
media_type: str = "application/json",
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
@@ -600,9 +589,7 @@ class Form(Body): # type: ignore[misc]
|
||||
media_type: str = "application/x-www-form-urlencoded",
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
@@ -684,9 +671,7 @@ class File(Form): # type: ignore[misc]
|
||||
media_type: str = "multipart/form-data",
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
validation_alias: Union[str, AliasPath, AliasChoices, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
|
||||
@@ -2,7 +2,6 @@ import email.message
|
||||
import functools
|
||||
import inspect
|
||||
import json
|
||||
import warnings
|
||||
from collections.abc import (
|
||||
AsyncIterator,
|
||||
Awaitable,
|
||||
@@ -22,16 +21,12 @@ from typing import (
|
||||
)
|
||||
|
||||
from annotated_doc import Doc
|
||||
from fastapi import params, temp_pydantic_v1_params
|
||||
from fastapi import params
|
||||
from fastapi._compat import (
|
||||
ModelField,
|
||||
Undefined,
|
||||
_get_model_config,
|
||||
_model_dump,
|
||||
_normalize_errors,
|
||||
annotation_is_pydantic_v1,
|
||||
lenient_issubclass,
|
||||
may_v1,
|
||||
)
|
||||
from fastapi.datastructures import Default, DefaultPlaceholder
|
||||
from fastapi.dependencies.models import Dependant
|
||||
@@ -47,8 +42,8 @@ from fastapi.dependencies.utils import (
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.exceptions import (
|
||||
EndpointContext,
|
||||
FastAPIDeprecationWarning,
|
||||
FastAPIError,
|
||||
PydanticV1NotSupportedError,
|
||||
RequestValidationError,
|
||||
ResponseValidationError,
|
||||
WebSocketRequestValidationError,
|
||||
@@ -148,51 +143,6 @@ def websocket_session(
|
||||
return app
|
||||
|
||||
|
||||
def _prepare_response_content(
|
||||
res: Any,
|
||||
*,
|
||||
exclude_unset: bool,
|
||||
exclude_defaults: bool = False,
|
||||
exclude_none: bool = False,
|
||||
) -> Any:
|
||||
if isinstance(res, may_v1.BaseModel):
|
||||
read_with_orm_mode = getattr(_get_model_config(res), "read_with_orm_mode", None) # type: ignore[arg-type]
|
||||
if read_with_orm_mode:
|
||||
# Let from_orm extract the data from this model instead of converting
|
||||
# it now to a dict.
|
||||
# Otherwise, there's no way to extract lazy data that requires attribute
|
||||
# access instead of dict iteration, e.g. lazy relationships.
|
||||
return res
|
||||
return _model_dump(
|
||||
res, # type: ignore[arg-type]
|
||||
by_alias=True,
|
||||
exclude_unset=exclude_unset,
|
||||
exclude_defaults=exclude_defaults,
|
||||
exclude_none=exclude_none,
|
||||
)
|
||||
elif isinstance(res, list):
|
||||
return [
|
||||
_prepare_response_content(
|
||||
item,
|
||||
exclude_unset=exclude_unset,
|
||||
exclude_defaults=exclude_defaults,
|
||||
exclude_none=exclude_none,
|
||||
)
|
||||
for item in res
|
||||
]
|
||||
elif isinstance(res, dict):
|
||||
return {
|
||||
k: _prepare_response_content(
|
||||
v,
|
||||
exclude_unset=exclude_unset,
|
||||
exclude_defaults=exclude_defaults,
|
||||
exclude_none=exclude_none,
|
||||
)
|
||||
for k, v in res.items()
|
||||
}
|
||||
return res
|
||||
|
||||
|
||||
def _merge_lifespan_context(
|
||||
original_context: Lifespan[Any], nested_context: Lifespan[Any]
|
||||
) -> Lifespan[Any]:
|
||||
@@ -252,14 +202,6 @@ async def serialize_response(
|
||||
) -> Any:
|
||||
if field:
|
||||
errors = []
|
||||
if not hasattr(field, "serialize"):
|
||||
# pydantic v1
|
||||
response_content = _prepare_response_content(
|
||||
response_content,
|
||||
exclude_unset=exclude_unset,
|
||||
exclude_defaults=exclude_defaults,
|
||||
exclude_none=exclude_none,
|
||||
)
|
||||
if is_coroutine:
|
||||
value, errors_ = field.validate(response_content, {}, loc=("response",))
|
||||
else:
|
||||
@@ -268,28 +210,15 @@ async def serialize_response(
|
||||
)
|
||||
if isinstance(errors_, list):
|
||||
errors.extend(errors_)
|
||||
elif errors_:
|
||||
errors.append(errors_)
|
||||
if errors:
|
||||
ctx = endpoint_ctx or EndpointContext()
|
||||
raise ResponseValidationError(
|
||||
errors=_normalize_errors(errors),
|
||||
errors=errors,
|
||||
body=response_content,
|
||||
endpoint_ctx=ctx,
|
||||
)
|
||||
|
||||
if hasattr(field, "serialize"):
|
||||
return field.serialize(
|
||||
value,
|
||||
include=include,
|
||||
exclude=exclude,
|
||||
by_alias=by_alias,
|
||||
exclude_unset=exclude_unset,
|
||||
exclude_defaults=exclude_defaults,
|
||||
exclude_none=exclude_none,
|
||||
)
|
||||
|
||||
return jsonable_encoder(
|
||||
return field.serialize(
|
||||
value,
|
||||
include=include,
|
||||
exclude=exclude,
|
||||
@@ -298,6 +227,7 @@ async def serialize_response(
|
||||
exclude_defaults=exclude_defaults,
|
||||
exclude_none=exclude_none,
|
||||
)
|
||||
|
||||
else:
|
||||
return jsonable_encoder(response_content)
|
||||
|
||||
@@ -332,9 +262,7 @@ def get_request_handler(
|
||||
) -> Callable[[Request], Coroutine[Any, Any, Response]]:
|
||||
assert dependant.call is not None, "dependant.call must be a function"
|
||||
is_coroutine = dependant.is_coroutine_callable
|
||||
is_body_form = body_field and isinstance(
|
||||
body_field.field_info, (params.Form, temp_pydantic_v1_params.Form)
|
||||
)
|
||||
is_body_form = body_field and isinstance(body_field.field_info, params.Form)
|
||||
if isinstance(response_class, DefaultPlaceholder):
|
||||
actual_response_class: type[Response] = response_class.value
|
||||
else:
|
||||
@@ -464,7 +392,7 @@ def get_request_handler(
|
||||
response.headers.raw.extend(solved_result.response.headers.raw)
|
||||
if errors:
|
||||
validation_error = RequestValidationError(
|
||||
_normalize_errors(errors), body=body, endpoint_ctx=endpoint_ctx
|
||||
errors, body=body, endpoint_ctx=endpoint_ctx
|
||||
)
|
||||
raise validation_error
|
||||
|
||||
@@ -503,7 +431,7 @@ def get_websocket_app(
|
||||
)
|
||||
if solved_result.errors:
|
||||
raise WebSocketRequestValidationError(
|
||||
_normalize_errors(solved_result.errors),
|
||||
solved_result.errors,
|
||||
endpoint_ctx=endpoint_ctx,
|
||||
)
|
||||
assert dependant.call is not None, "dependant.call must be a function"
|
||||
@@ -638,11 +566,9 @@ class APIRoute(routing.Route):
|
||||
)
|
||||
response_name = "Response_" + self.unique_id
|
||||
if annotation_is_pydantic_v1(self.response_model):
|
||||
warnings.warn(
|
||||
"pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
|
||||
f" Please update the response model {self.response_model!r}.",
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
raise PydanticV1NotSupportedError(
|
||||
"pydantic.v1 models are no longer supported by FastAPI."
|
||||
f" Please update the response model {self.response_model!r}."
|
||||
)
|
||||
self.response_field = create_model_field(
|
||||
name=response_name,
|
||||
@@ -678,11 +604,9 @@ class APIRoute(routing.Route):
|
||||
)
|
||||
response_name = f"Response_{additional_status_code}_{self.unique_id}"
|
||||
if annotation_is_pydantic_v1(model):
|
||||
warnings.warn(
|
||||
"pydantic.v1 is deprecated and will soon stop being supported by FastAPI."
|
||||
f" In responses={{}}, please update {model}.",
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
raise PydanticV1NotSupportedError(
|
||||
"pydantic.v1 models are no longer supported by FastAPI."
|
||||
f" In responses={{}}, please update {model}."
|
||||
)
|
||||
response_field = create_model_field(
|
||||
name=response_name, type_=model, mode="serialization"
|
||||
|
||||
@@ -1,718 +0,0 @@
|
||||
import warnings
|
||||
from typing import Annotated, Any, Callable, Optional, Union
|
||||
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.openapi.models import Example
|
||||
from fastapi.params import ParamTypes
|
||||
from typing_extensions import deprecated
|
||||
|
||||
from ._compat.may_v1 import FieldInfo, Undefined
|
||||
|
||||
_Unset: Any = Undefined
|
||||
|
||||
|
||||
class Param(FieldInfo):
|
||||
in_: ParamTypes
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = Undefined,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
if example is not _Unset:
|
||||
warnings.warn(
|
||||
"`example` has been deprecated, please use `examples` instead",
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
self.example = example
|
||||
self.include_in_schema = include_in_schema
|
||||
self.openapi_examples = openapi_examples
|
||||
kwargs = dict(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
alias=alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
discriminator=discriminator,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
**extra,
|
||||
)
|
||||
if examples is not None:
|
||||
kwargs["examples"] = examples
|
||||
if regex is not None:
|
||||
warnings.warn(
|
||||
"`regex` has been deprecated, please use `pattern` instead",
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
kwargs["deprecated"] = deprecated
|
||||
kwargs["regex"] = pattern or regex
|
||||
kwargs.update(**current_json_schema_extra)
|
||||
use_kwargs = {k: v for k, v in kwargs.items() if v is not _Unset}
|
||||
|
||||
super().__init__(**use_kwargs)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{self.__class__.__name__}({self.default})"
|
||||
|
||||
|
||||
class Path(Param):
|
||||
in_ = ParamTypes.path
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = ...,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
assert default is ..., "Path parameters cannot have a default value"
|
||||
self.in_ = self.in_
|
||||
super().__init__(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
annotation=annotation,
|
||||
alias=alias,
|
||||
alias_priority=alias_priority,
|
||||
validation_alias=validation_alias,
|
||||
serialization_alias=serialization_alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
pattern=pattern,
|
||||
regex=regex,
|
||||
discriminator=discriminator,
|
||||
strict=strict,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
deprecated=deprecated,
|
||||
example=example,
|
||||
examples=examples,
|
||||
openapi_examples=openapi_examples,
|
||||
include_in_schema=include_in_schema,
|
||||
json_schema_extra=json_schema_extra,
|
||||
**extra,
|
||||
)
|
||||
|
||||
|
||||
class Query(Param):
|
||||
in_ = ParamTypes.query
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = Undefined,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
super().__init__(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
annotation=annotation,
|
||||
alias=alias,
|
||||
alias_priority=alias_priority,
|
||||
validation_alias=validation_alias,
|
||||
serialization_alias=serialization_alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
pattern=pattern,
|
||||
regex=regex,
|
||||
discriminator=discriminator,
|
||||
strict=strict,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
deprecated=deprecated,
|
||||
example=example,
|
||||
examples=examples,
|
||||
openapi_examples=openapi_examples,
|
||||
include_in_schema=include_in_schema,
|
||||
json_schema_extra=json_schema_extra,
|
||||
**extra,
|
||||
)
|
||||
|
||||
|
||||
class Header(Param):
|
||||
in_ = ParamTypes.header
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = Undefined,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
convert_underscores: bool = True,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
self.convert_underscores = convert_underscores
|
||||
super().__init__(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
annotation=annotation,
|
||||
alias=alias,
|
||||
alias_priority=alias_priority,
|
||||
validation_alias=validation_alias,
|
||||
serialization_alias=serialization_alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
pattern=pattern,
|
||||
regex=regex,
|
||||
discriminator=discriminator,
|
||||
strict=strict,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
deprecated=deprecated,
|
||||
example=example,
|
||||
examples=examples,
|
||||
openapi_examples=openapi_examples,
|
||||
include_in_schema=include_in_schema,
|
||||
json_schema_extra=json_schema_extra,
|
||||
**extra,
|
||||
)
|
||||
|
||||
|
||||
class Cookie(Param):
|
||||
in_ = ParamTypes.cookie
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = Undefined,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
super().__init__(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
annotation=annotation,
|
||||
alias=alias,
|
||||
alias_priority=alias_priority,
|
||||
validation_alias=validation_alias,
|
||||
serialization_alias=serialization_alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
pattern=pattern,
|
||||
regex=regex,
|
||||
discriminator=discriminator,
|
||||
strict=strict,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
deprecated=deprecated,
|
||||
example=example,
|
||||
examples=examples,
|
||||
openapi_examples=openapi_examples,
|
||||
include_in_schema=include_in_schema,
|
||||
json_schema_extra=json_schema_extra,
|
||||
**extra,
|
||||
)
|
||||
|
||||
|
||||
class Body(FieldInfo):
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = Undefined,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
embed: Union[bool, None] = None,
|
||||
media_type: str = "application/json",
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
self.embed = embed
|
||||
self.media_type = media_type
|
||||
if example is not _Unset:
|
||||
warnings.warn(
|
||||
"`example` has been deprecated, please use `examples` instead",
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
self.example = example
|
||||
self.include_in_schema = include_in_schema
|
||||
self.openapi_examples = openapi_examples
|
||||
kwargs = dict(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
alias=alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
discriminator=discriminator,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
**extra,
|
||||
)
|
||||
if examples is not None:
|
||||
kwargs["examples"] = examples
|
||||
if regex is not None:
|
||||
warnings.warn(
|
||||
"`regex` has been deprecated, please use `pattern` instead",
|
||||
category=FastAPIDeprecationWarning,
|
||||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
kwargs["deprecated"] = deprecated
|
||||
kwargs["regex"] = pattern or regex
|
||||
kwargs.update(**current_json_schema_extra)
|
||||
|
||||
use_kwargs = {k: v for k, v in kwargs.items() if v is not _Unset}
|
||||
|
||||
super().__init__(**use_kwargs)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{self.__class__.__name__}({self.default})"
|
||||
|
||||
|
||||
class Form(Body):
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = Undefined,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
media_type: str = "application/x-www-form-urlencoded",
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
super().__init__(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
annotation=annotation,
|
||||
media_type=media_type,
|
||||
alias=alias,
|
||||
alias_priority=alias_priority,
|
||||
validation_alias=validation_alias,
|
||||
serialization_alias=serialization_alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
pattern=pattern,
|
||||
regex=regex,
|
||||
discriminator=discriminator,
|
||||
strict=strict,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
deprecated=deprecated,
|
||||
example=example,
|
||||
examples=examples,
|
||||
openapi_examples=openapi_examples,
|
||||
include_in_schema=include_in_schema,
|
||||
json_schema_extra=json_schema_extra,
|
||||
**extra,
|
||||
)
|
||||
|
||||
|
||||
class File(Form):
|
||||
def __init__(
|
||||
self,
|
||||
default: Any = Undefined,
|
||||
*,
|
||||
default_factory: Union[Callable[[], Any], None] = _Unset,
|
||||
annotation: Optional[Any] = None,
|
||||
media_type: str = "multipart/form-data",
|
||||
alias: Optional[str] = None,
|
||||
alias_priority: Union[int, None] = _Unset,
|
||||
# TODO: update when deprecating Pydantic v1, import these types
|
||||
# validation_alias: str | AliasPath | AliasChoices | None
|
||||
validation_alias: Union[str, None] = None,
|
||||
serialization_alias: Union[str, None] = None,
|
||||
title: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
gt: Optional[float] = None,
|
||||
ge: Optional[float] = None,
|
||||
lt: Optional[float] = None,
|
||||
le: Optional[float] = None,
|
||||
min_length: Optional[int] = None,
|
||||
max_length: Optional[int] = None,
|
||||
pattern: Optional[str] = None,
|
||||
regex: Annotated[
|
||||
Optional[str],
|
||||
deprecated(
|
||||
"Deprecated in FastAPI 0.100.0 and Pydantic v2, use `pattern` instead."
|
||||
),
|
||||
] = None,
|
||||
discriminator: Union[str, None] = None,
|
||||
strict: Union[bool, None] = _Unset,
|
||||
multiple_of: Union[float, None] = _Unset,
|
||||
allow_inf_nan: Union[bool, None] = _Unset,
|
||||
max_digits: Union[int, None] = _Unset,
|
||||
decimal_places: Union[int, None] = _Unset,
|
||||
examples: Optional[list[Any]] = None,
|
||||
example: Annotated[
|
||||
Optional[Any],
|
||||
deprecated(
|
||||
"Deprecated in OpenAPI 3.1.0 that now uses JSON Schema 2020-12, "
|
||||
"although still supported. Use examples instead."
|
||||
),
|
||||
] = _Unset,
|
||||
openapi_examples: Optional[dict[str, Example]] = None,
|
||||
deprecated: Union[deprecated, str, bool, None] = None,
|
||||
include_in_schema: bool = True,
|
||||
json_schema_extra: Union[dict[str, Any], None] = None,
|
||||
**extra: Any,
|
||||
):
|
||||
super().__init__(
|
||||
default=default,
|
||||
default_factory=default_factory,
|
||||
annotation=annotation,
|
||||
media_type=media_type,
|
||||
alias=alias,
|
||||
alias_priority=alias_priority,
|
||||
validation_alias=validation_alias,
|
||||
serialization_alias=serialization_alias,
|
||||
title=title,
|
||||
description=description,
|
||||
gt=gt,
|
||||
ge=ge,
|
||||
lt=lt,
|
||||
le=le,
|
||||
min_length=min_length,
|
||||
max_length=max_length,
|
||||
pattern=pattern,
|
||||
regex=regex,
|
||||
discriminator=discriminator,
|
||||
strict=strict,
|
||||
multiple_of=multiple_of,
|
||||
allow_inf_nan=allow_inf_nan,
|
||||
max_digits=max_digits,
|
||||
decimal_places=decimal_places,
|
||||
deprecated=deprecated,
|
||||
example=example,
|
||||
examples=examples,
|
||||
openapi_examples=openapi_examples,
|
||||
include_in_schema=include_in_schema,
|
||||
json_schema_extra=json_schema_extra,
|
||||
**extra,
|
||||
)
|
||||
109
fastapi/utils.py
109
fastapi/utils.py
@@ -6,7 +6,6 @@ from typing import (
|
||||
Any,
|
||||
Optional,
|
||||
Union,
|
||||
cast,
|
||||
)
|
||||
from weakref import WeakKeyDictionary
|
||||
|
||||
@@ -19,11 +18,9 @@ from fastapi._compat import (
|
||||
UndefinedType,
|
||||
Validator,
|
||||
annotation_is_pydantic_v1,
|
||||
lenient_issubclass,
|
||||
may_v1,
|
||||
)
|
||||
from fastapi.datastructures import DefaultPlaceholder, DefaultType
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning, PydanticV1NotSupportedError
|
||||
from pydantic import BaseModel
|
||||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import Literal
|
||||
@@ -83,52 +80,18 @@ def create_model_field(
|
||||
mode: Literal["validation", "serialization"] = "validation",
|
||||
version: Literal["1", "auto"] = "auto",
|
||||
) -> ModelField:
|
||||
if annotation_is_pydantic_v1(type_):
|
||||
raise PydanticV1NotSupportedError(
|
||||
"pydantic.v1 models are no longer supported by FastAPI."
|
||||
f" Please update the response model {type_!r}."
|
||||
)
|
||||
class_validators = class_validators or {}
|
||||
|
||||
v1_model_config = may_v1.BaseConfig
|
||||
v1_field_info = field_info or may_v1.FieldInfo()
|
||||
v1_kwargs = {
|
||||
"name": name,
|
||||
"field_info": v1_field_info,
|
||||
"type_": type_,
|
||||
"class_validators": class_validators,
|
||||
"default": default,
|
||||
"required": required,
|
||||
"model_config": v1_model_config,
|
||||
"alias": alias,
|
||||
}
|
||||
|
||||
if (
|
||||
annotation_is_pydantic_v1(type_)
|
||||
or isinstance(field_info, may_v1.FieldInfo)
|
||||
or version == "1"
|
||||
):
|
||||
from fastapi._compat import v1
|
||||
|
||||
try:
|
||||
return v1.ModelField(**v1_kwargs) # type: ignore[return-value]
|
||||
except RuntimeError:
|
||||
raise fastapi.exceptions.FastAPIError(
|
||||
_invalid_args_message.format(type_=type_)
|
||||
) from None
|
||||
else:
|
||||
field_info = field_info or FieldInfo(
|
||||
annotation=type_, default=default, alias=alias
|
||||
)
|
||||
kwargs = {"mode": mode, "name": name, "field_info": field_info}
|
||||
try:
|
||||
return v2.ModelField(**kwargs) # type: ignore[return-value,arg-type]
|
||||
except PydanticSchemaGenerationError:
|
||||
raise fastapi.exceptions.FastAPIError(
|
||||
_invalid_args_message.format(type_=type_)
|
||||
) from None
|
||||
# Pydantic v2 is not installed, but it's not a Pydantic v1 ModelField, it could be
|
||||
# a Pydantic v1 type, like a constrained int
|
||||
from fastapi._compat import v1
|
||||
|
||||
field_info = field_info or FieldInfo(annotation=type_, default=default, alias=alias)
|
||||
kwargs = {"mode": mode, "name": name, "field_info": field_info}
|
||||
try:
|
||||
return v1.ModelField(**v1_kwargs)
|
||||
except RuntimeError:
|
||||
return v2.ModelField(**kwargs) # type: ignore[return-value,arg-type]
|
||||
except PydanticSchemaGenerationError:
|
||||
raise fastapi.exceptions.FastAPIError(
|
||||
_invalid_args_message.format(type_=type_)
|
||||
) from None
|
||||
@@ -139,57 +102,7 @@ def create_cloned_field(
|
||||
*,
|
||||
cloned_types: Optional[MutableMapping[type[BaseModel], type[BaseModel]]] = None,
|
||||
) -> ModelField:
|
||||
if isinstance(field, v2.ModelField):
|
||||
return field
|
||||
|
||||
from fastapi._compat import v1
|
||||
|
||||
# cloned_types caches already cloned types to support recursive models and improve
|
||||
# performance by avoiding unnecessary cloning
|
||||
if cloned_types is None:
|
||||
cloned_types = _CLONED_TYPES_CACHE
|
||||
|
||||
original_type = field.type_
|
||||
use_type = original_type
|
||||
if lenient_issubclass(original_type, v1.BaseModel):
|
||||
original_type = cast(type[v1.BaseModel], original_type)
|
||||
use_type = cloned_types.get(original_type)
|
||||
if use_type is None:
|
||||
use_type = v1.create_model(original_type.__name__, __base__=original_type)
|
||||
cloned_types[original_type] = use_type
|
||||
for f in original_type.__fields__.values():
|
||||
use_type.__fields__[f.name] = create_cloned_field(
|
||||
f,
|
||||
cloned_types=cloned_types,
|
||||
)
|
||||
new_field = create_model_field(name=field.name, type_=use_type, version="1")
|
||||
new_field.has_alias = field.has_alias # type: ignore[attr-defined]
|
||||
new_field.alias = field.alias # type: ignore[misc]
|
||||
new_field.class_validators = field.class_validators # type: ignore[attr-defined]
|
||||
new_field.default = field.default # type: ignore[misc]
|
||||
new_field.default_factory = field.default_factory # type: ignore[attr-defined]
|
||||
new_field.required = field.required # type: ignore[misc]
|
||||
new_field.model_config = field.model_config # type: ignore[attr-defined]
|
||||
new_field.field_info = field.field_info
|
||||
new_field.allow_none = field.allow_none # type: ignore[attr-defined]
|
||||
new_field.validate_always = field.validate_always # type: ignore[attr-defined]
|
||||
if field.sub_fields: # type: ignore[attr-defined]
|
||||
new_field.sub_fields = [ # type: ignore[attr-defined]
|
||||
create_cloned_field(sub_field, cloned_types=cloned_types)
|
||||
for sub_field in field.sub_fields # type: ignore[attr-defined]
|
||||
]
|
||||
if field.key_field: # type: ignore[attr-defined]
|
||||
new_field.key_field = create_cloned_field( # type: ignore[attr-defined]
|
||||
field.key_field, # type: ignore[attr-defined]
|
||||
cloned_types=cloned_types,
|
||||
)
|
||||
new_field.validators = field.validators # type: ignore[attr-defined]
|
||||
new_field.pre_validators = field.pre_validators # type: ignore[attr-defined]
|
||||
new_field.post_validators = field.post_validators # type: ignore[attr-defined]
|
||||
new_field.parse_json = field.parse_json # type: ignore[attr-defined]
|
||||
new_field.shape = field.shape # type: ignore[attr-defined]
|
||||
new_field.populate_validators() # type: ignore[attr-defined]
|
||||
return new_field
|
||||
return field
|
||||
|
||||
|
||||
def generate_operation_id_for_path(
|
||||
|
||||
@@ -199,14 +199,22 @@ omit = [
|
||||
"docs_src/dependencies/tutorial008_an_py39.py", # difficult to mock
|
||||
"docs_src/dependencies/tutorial013_an_py310.py", # temporary code example?
|
||||
"docs_src/dependencies/tutorial014_an_py310.py", # temporary code example?
|
||||
# Pydantic V1
|
||||
# Pydantic v1 migration, no longer tested
|
||||
"docs_src/pydantic_v1_in_v2/tutorial001_an_py310.py",
|
||||
"docs_src/pydantic_v1_in_v2/tutorial001_an_py39.py",
|
||||
"docs_src/pydantic_v1_in_v2/tutorial002_an_py310.py",
|
||||
"docs_src/pydantic_v1_in_v2/tutorial002_an_py39.py",
|
||||
"docs_src/pydantic_v1_in_v2/tutorial003_an_py310.py",
|
||||
"docs_src/pydantic_v1_in_v2/tutorial003_an_py39.py",
|
||||
"docs_src/pydantic_v1_in_v2/tutorial004_an_py310.py",
|
||||
"docs_src/pydantic_v1_in_v2/tutorial004_an_py39.py",
|
||||
# TODO: remove when removing this file, after updating translations, Pydantic v1
|
||||
"docs_src/schema_extra_example/tutorial001_pv1_py310.py",
|
||||
"docs_src/query_param_models/tutorial002_pv1_py310.py",
|
||||
"docs_src/query_param_models/tutorial002_pv1_an_py310.py",
|
||||
"docs_src/header_param_models/tutorial002_pv1_py310.py",
|
||||
"docs_src/header_param_models/tutorial002_pv1_an_py310.py",
|
||||
"docs_src/cookie_param_models/tutorial002_pv1_py310.py",
|
||||
"docs_src/cookie_param_models/tutorial002_pv1_an_py310.py",
|
||||
"docs_src/schema_extra_example/tutorial001_pv1_py39.py",
|
||||
"docs_src/path_operation_advanced_configuration/tutorial007_pv1_py39.py",
|
||||
"docs_src/settings/app03_py39/config_pv1.py",
|
||||
"docs_src/settings/app03_an_py39/config_pv1.py",
|
||||
"docs_src/settings/tutorial001_pv1_py39.py",
|
||||
]
|
||||
|
||||
[tool.coverage.report]
|
||||
|
||||
729
scripts/doc_parsing_utils.py
Normal file
729
scripts/doc_parsing_utils.py
Normal file
@@ -0,0 +1,729 @@
|
||||
import re
|
||||
from typing import TypedDict
|
||||
|
||||
CODE_INCLUDE_RE = re.compile(r"^\{\*\s*(\S+)\s*(.*)\*\}$")
|
||||
CODE_INCLUDE_PLACEHOLDER = "<CODE_INCLUDE>"
|
||||
|
||||
HEADER_WITH_PERMALINK_RE = re.compile(r"^(#{1,6}) (.+?)(\s*\{\s*#.*\s*\})?\s*$")
|
||||
HEADER_LINE_RE = re.compile(r"^(#{1,6}) (.+?)(?:\s*\{\s*(#.*)\s*\})?\s*$")
|
||||
|
||||
TIANGOLO_COM = "https://fastapi.tiangolo.com"
|
||||
ASSETS_URL_PREFIXES = ("/img/", "/css/", "/js/")
|
||||
|
||||
MARKDOWN_LINK_RE = re.compile(
|
||||
r"(?<!\\)(?<!\!)" # not an image ![...] and not escaped \[...]
|
||||
r"\[(?P<text>.*?)\]" # link text (non-greedy)
|
||||
r"\("
|
||||
r"(?P<url>[^)\s]+)" # url (no spaces and `)`)
|
||||
r'(?:\s+["\'](?P<title>.*?)["\'])?' # optional title in "" or ''
|
||||
r"\)"
|
||||
r"(?:\s*\{(?P<attrs>[^}]*)\})?" # optional attributes in {}
|
||||
)
|
||||
|
||||
HTML_LINK_RE = re.compile(r"<a\s+[^>]*>.*?</a>")
|
||||
HTML_LINK_TEXT_RE = re.compile(r"<a\b([^>]*)>(.*?)</a>")
|
||||
HTML_LINK_OPEN_TAG_RE = re.compile(r"<a\b([^>]*)>")
|
||||
HTML_ATTR_RE = re.compile(r'(\w+)\s*=\s*([\'"])(.*?)\2')
|
||||
|
||||
CODE_BLOCK_LANG_RE = re.compile(r"^`{3,4}([\w-]*)", re.MULTILINE)
|
||||
|
||||
SLASHES_COMMENT_RE = re.compile(
|
||||
r"^(?P<code>.*?)(?P<comment>(?:(?<= )// .*)|(?:^// .*))?$"
|
||||
)
|
||||
|
||||
HASH_COMMENT_RE = re.compile(r"^(?P<code>.*?)(?P<comment>(?:(?<= )# .*)|(?:^# .*))?$")
|
||||
|
||||
|
||||
class CodeIncludeInfo(TypedDict):
|
||||
line_no: int
|
||||
line: str
|
||||
|
||||
|
||||
class HeaderPermalinkInfo(TypedDict):
|
||||
line_no: int
|
||||
hashes: str
|
||||
title: str
|
||||
permalink: str
|
||||
|
||||
|
||||
class MarkdownLinkInfo(TypedDict):
|
||||
line_no: int
|
||||
url: str
|
||||
text: str
|
||||
title: str | None
|
||||
attributes: str | None
|
||||
full_match: str
|
||||
|
||||
|
||||
class HTMLLinkAttribute(TypedDict):
|
||||
name: str
|
||||
quote: str
|
||||
value: str
|
||||
|
||||
|
||||
class HtmlLinkInfo(TypedDict):
|
||||
line_no: int
|
||||
full_tag: str
|
||||
attributes: list[HTMLLinkAttribute]
|
||||
text: str
|
||||
|
||||
|
||||
class MultilineCodeBlockInfo(TypedDict):
|
||||
lang: str
|
||||
start_line_no: int
|
||||
content: list[str]
|
||||
|
||||
|
||||
# Code includes
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def extract_code_includes(lines: list[str]) -> list[CodeIncludeInfo]:
|
||||
"""
|
||||
Exctract lines that contain code includes.
|
||||
|
||||
Return list of CodeIncludeInfo namedtuples, where each tuple contains:
|
||||
- `line_no` - line number (1-based)
|
||||
- `line` - text of the line
|
||||
"""
|
||||
|
||||
includes: list[CodeIncludeInfo] = []
|
||||
for line_no, line in enumerate(lines, start=1):
|
||||
if CODE_INCLUDE_RE.match(line):
|
||||
includes.append(CodeIncludeInfo(line_no=line_no, line=line))
|
||||
return includes
|
||||
|
||||
|
||||
def replace_code_includes_with_placeholders(text: list[str]) -> list[str]:
|
||||
"""
|
||||
Replace code includes with placeholders.
|
||||
"""
|
||||
|
||||
modified_text = text.copy()
|
||||
includes = extract_code_includes(text)
|
||||
for include in includes:
|
||||
modified_text[include["line_no"] - 1] = CODE_INCLUDE_PLACEHOLDER
|
||||
return modified_text
|
||||
|
||||
|
||||
def replace_placeholders_with_code_includes(
|
||||
text: list[str], original_includes: list[CodeIncludeInfo]
|
||||
) -> list[str]:
|
||||
"""
|
||||
Replace code includes placeholders with actual code includes from the original (English) document.
|
||||
Fail if the number of placeholders does not match the number of original includes.
|
||||
"""
|
||||
|
||||
code_include_lines = [
|
||||
line_no
|
||||
for line_no, line in enumerate(text)
|
||||
if line.strip() == CODE_INCLUDE_PLACEHOLDER
|
||||
]
|
||||
|
||||
if len(code_include_lines) != len(original_includes):
|
||||
raise ValueError(
|
||||
"Number of code include placeholders does not match the number of code includes "
|
||||
"in the original document "
|
||||
f"({len(code_include_lines)} vs {len(original_includes)})"
|
||||
)
|
||||
|
||||
modified_text = text.copy()
|
||||
for i, line_no in enumerate(code_include_lines):
|
||||
modified_text[line_no] = original_includes[i]["line"]
|
||||
|
||||
return modified_text
|
||||
|
||||
|
||||
# Header permalinks
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def extract_header_permalinks(lines: list[str]) -> list[HeaderPermalinkInfo]:
|
||||
"""
|
||||
Extract list of header permalinks from the given lines.
|
||||
|
||||
Return list of HeaderPermalinkInfo namedtuples, where each tuple contains:
|
||||
- `line_no` - line number (1-based)
|
||||
- `hashes` - string of hashes representing header level (e.g., "###")
|
||||
- `permalink` - permalink string (e.g., "{#permalink}")
|
||||
"""
|
||||
|
||||
headers: list[HeaderPermalinkInfo] = []
|
||||
in_code_block3 = False
|
||||
in_code_block4 = False
|
||||
|
||||
for line_no, line in enumerate(lines, start=1):
|
||||
if not (in_code_block3 or in_code_block4):
|
||||
if line.startswith("```"):
|
||||
count = len(line) - len(line.lstrip("`"))
|
||||
if count == 3:
|
||||
in_code_block3 = True
|
||||
continue
|
||||
elif count >= 4:
|
||||
in_code_block4 = True
|
||||
continue
|
||||
|
||||
header_match = HEADER_WITH_PERMALINK_RE.match(line)
|
||||
if header_match:
|
||||
hashes, title, permalink = header_match.groups()
|
||||
headers.append(
|
||||
HeaderPermalinkInfo(
|
||||
hashes=hashes, line_no=line_no, permalink=permalink, title=title
|
||||
)
|
||||
)
|
||||
|
||||
elif in_code_block3:
|
||||
if line.startswith("```"):
|
||||
count = len(line) - len(line.lstrip("`"))
|
||||
if count == 3:
|
||||
in_code_block3 = False
|
||||
continue
|
||||
|
||||
elif in_code_block4:
|
||||
if line.startswith("````"):
|
||||
count = len(line) - len(line.lstrip("`"))
|
||||
if count >= 4:
|
||||
in_code_block4 = False
|
||||
continue
|
||||
|
||||
return headers
|
||||
|
||||
|
||||
def remove_header_permalinks(lines: list[str]) -> list[str]:
|
||||
"""
|
||||
Remove permalinks from headers in the given lines.
|
||||
"""
|
||||
|
||||
modified_lines: list[str] = []
|
||||
for line in lines:
|
||||
header_match = HEADER_WITH_PERMALINK_RE.match(line)
|
||||
if header_match:
|
||||
hashes, title, _permalink = header_match.groups()
|
||||
modified_line = f"{hashes} {title}"
|
||||
modified_lines.append(modified_line)
|
||||
else:
|
||||
modified_lines.append(line)
|
||||
return modified_lines
|
||||
|
||||
|
||||
def replace_header_permalinks(
|
||||
text: list[str],
|
||||
header_permalinks: list[HeaderPermalinkInfo],
|
||||
original_header_permalinks: list[HeaderPermalinkInfo],
|
||||
) -> list[str]:
|
||||
"""
|
||||
Replace permalinks in the given text with the permalinks from the original document.
|
||||
|
||||
Fail if the number or level of headers does not match the original.
|
||||
"""
|
||||
|
||||
modified_text: list[str] = text.copy()
|
||||
|
||||
if len(header_permalinks) != len(original_header_permalinks):
|
||||
raise ValueError(
|
||||
"Number of headers with permalinks does not match the number in the "
|
||||
"original document "
|
||||
f"({len(header_permalinks)} vs {len(original_header_permalinks)})"
|
||||
)
|
||||
|
||||
for header_no in range(len(header_permalinks)):
|
||||
header_info = header_permalinks[header_no]
|
||||
original_header_info = original_header_permalinks[header_no]
|
||||
|
||||
if header_info["hashes"] != original_header_info["hashes"]:
|
||||
raise ValueError(
|
||||
"Header levels do not match between document and original document"
|
||||
f" (found {header_info['hashes']}, expected {original_header_info['hashes']})"
|
||||
f" for header №{header_no + 1} in line {header_info['line_no']}"
|
||||
)
|
||||
line_no = header_info["line_no"] - 1
|
||||
hashes = header_info["hashes"]
|
||||
title = header_info["title"]
|
||||
permalink = original_header_info["permalink"]
|
||||
modified_text[line_no] = f"{hashes} {title}{permalink}"
|
||||
|
||||
return modified_text
|
||||
|
||||
|
||||
# Markdown links
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def extract_markdown_links(lines: list[str]) -> list[tuple[str, int]]:
|
||||
"""
|
||||
Extract all markdown links from the given lines.
|
||||
|
||||
Return list of MarkdownLinkInfo namedtuples, where each tuple contains:
|
||||
- `line_no` - line number (1-based)
|
||||
- `url` - link URL
|
||||
- `text` - link text
|
||||
- `title` - link title (if any)
|
||||
"""
|
||||
|
||||
links: list[MarkdownLinkInfo] = []
|
||||
for line_no, line in enumerate(lines, start=1):
|
||||
for m in MARKDOWN_LINK_RE.finditer(line):
|
||||
links.append(
|
||||
MarkdownLinkInfo(
|
||||
line_no=line_no,
|
||||
url=m.group("url"),
|
||||
text=m.group("text"),
|
||||
title=m.group("title"),
|
||||
attributes=m.group("attrs"),
|
||||
full_match=m.group(0),
|
||||
)
|
||||
)
|
||||
return links
|
||||
|
||||
|
||||
def _add_lang_code_to_url(url: str, lang_code: str) -> str:
|
||||
if url.startswith(TIANGOLO_COM):
|
||||
rel_url = url[len(TIANGOLO_COM) :]
|
||||
if not rel_url.startswith(ASSETS_URL_PREFIXES):
|
||||
url = url.replace(TIANGOLO_COM, f"{TIANGOLO_COM}/{lang_code}")
|
||||
return url
|
||||
|
||||
|
||||
def _construct_markdown_link(
|
||||
url: str, text: str, title: str | None, attributes: str | None, lang_code: str
|
||||
) -> str:
|
||||
"""
|
||||
Construct a markdown link, adjusting the URL for the given language code if needed.
|
||||
"""
|
||||
url = _add_lang_code_to_url(url, lang_code)
|
||||
|
||||
if title:
|
||||
link = f'[{text}]({url} "{title}")'
|
||||
else:
|
||||
link = f"[{text}]({url})"
|
||||
|
||||
if attributes:
|
||||
link += f"{{{attributes}}}"
|
||||
|
||||
return link
|
||||
|
||||
|
||||
def replace_markdown_links(
|
||||
text: list[str],
|
||||
links: list[MarkdownLinkInfo],
|
||||
original_links: list[MarkdownLinkInfo],
|
||||
lang_code: str,
|
||||
) -> list[str]:
|
||||
"""
|
||||
Replace markdown links in the given text with the original links.
|
||||
|
||||
Fail if the number of links does not match the original.
|
||||
"""
|
||||
|
||||
if len(links) != len(original_links):
|
||||
raise ValueError(
|
||||
"Number of markdown links does not match the number in the "
|
||||
"original document "
|
||||
f"({len(links)} vs {len(original_links)})"
|
||||
)
|
||||
|
||||
modified_text = text.copy()
|
||||
for i, link_info in enumerate(links):
|
||||
link_text = link_info["text"]
|
||||
link_title = link_info["title"]
|
||||
original_link_info = original_links[i]
|
||||
|
||||
# Replace
|
||||
replacement_link = _construct_markdown_link(
|
||||
url=original_link_info["url"],
|
||||
text=link_text,
|
||||
title=link_title,
|
||||
attributes=original_link_info["attributes"],
|
||||
lang_code=lang_code,
|
||||
)
|
||||
line_no = link_info["line_no"] - 1
|
||||
modified_line = modified_text[line_no]
|
||||
modified_line = modified_line.replace(
|
||||
link_info["full_match"], replacement_link, 1
|
||||
)
|
||||
modified_text[line_no] = modified_line
|
||||
|
||||
return modified_text
|
||||
|
||||
|
||||
# HTML links
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def extract_html_links(lines: list[str]) -> list[HtmlLinkInfo]:
|
||||
"""
|
||||
Extract all HTML links from the given lines.
|
||||
|
||||
Return list of HtmlLinkInfo namedtuples, where each tuple contains:
|
||||
- `line_no` - line number (1-based)
|
||||
- `full_tag` - full HTML link tag
|
||||
- `attributes` - list of HTMLLinkAttribute namedtuples (name, quote, value)
|
||||
- `text` - link text
|
||||
"""
|
||||
|
||||
links = []
|
||||
for line_no, line in enumerate(lines, start=1):
|
||||
for html_link in HTML_LINK_RE.finditer(line):
|
||||
link_str = html_link.group(0)
|
||||
|
||||
link_text_match = HTML_LINK_TEXT_RE.match(link_str)
|
||||
assert link_text_match is not None
|
||||
link_text = link_text_match.group(2)
|
||||
assert isinstance(link_text, str)
|
||||
|
||||
link_open_tag_match = HTML_LINK_OPEN_TAG_RE.match(link_str)
|
||||
assert link_open_tag_match is not None
|
||||
link_open_tag = link_open_tag_match.group(1)
|
||||
assert isinstance(link_open_tag, str)
|
||||
|
||||
attributes: list[HTMLLinkAttribute] = []
|
||||
for attr_name, attr_quote, attr_value in re.findall(
|
||||
HTML_ATTR_RE, link_open_tag
|
||||
):
|
||||
assert isinstance(attr_name, str)
|
||||
assert isinstance(attr_quote, str)
|
||||
assert isinstance(attr_value, str)
|
||||
attributes.append(
|
||||
HTMLLinkAttribute(
|
||||
name=attr_name, quote=attr_quote, value=attr_value
|
||||
)
|
||||
)
|
||||
links.append(
|
||||
HtmlLinkInfo(
|
||||
line_no=line_no,
|
||||
full_tag=link_str,
|
||||
attributes=attributes,
|
||||
text=link_text,
|
||||
)
|
||||
)
|
||||
return links
|
||||
|
||||
|
||||
def _construct_html_link(
|
||||
link_text: str,
|
||||
attributes: list[HTMLLinkAttribute],
|
||||
lang_code: str,
|
||||
) -> str:
|
||||
"""
|
||||
Reconstruct HTML link, adjusting the URL for the given language code if needed.
|
||||
"""
|
||||
|
||||
attributes_upd: list[HTMLLinkAttribute] = []
|
||||
for attribute in attributes:
|
||||
if attribute["name"] == "href":
|
||||
original_url = attribute["value"]
|
||||
url = _add_lang_code_to_url(original_url, lang_code)
|
||||
attributes_upd.append(
|
||||
HTMLLinkAttribute(name="href", quote=attribute["quote"], value=url)
|
||||
)
|
||||
else:
|
||||
attributes_upd.append(attribute)
|
||||
|
||||
attrs_str = " ".join(
|
||||
f"{attribute['name']}={attribute['quote']}{attribute['value']}{attribute['quote']}"
|
||||
for attribute in attributes_upd
|
||||
)
|
||||
return f"<a {attrs_str}>{link_text}</a>"
|
||||
|
||||
|
||||
def replace_html_links(
|
||||
text: list[str],
|
||||
links: list[HtmlLinkInfo],
|
||||
original_links: list[HtmlLinkInfo],
|
||||
lang_code: str,
|
||||
) -> list[str]:
|
||||
"""
|
||||
Replace HTML links in the given text with the links from the original document.
|
||||
|
||||
Adjust URLs for the given language code.
|
||||
Fail if the number of links does not match the original.
|
||||
"""
|
||||
|
||||
if len(links) != len(original_links):
|
||||
raise ValueError(
|
||||
"Number of HTML links does not match the number in the "
|
||||
"original document "
|
||||
f"({len(links)} vs {len(original_links)})"
|
||||
)
|
||||
|
||||
modified_text = text.copy()
|
||||
for link_index, link in enumerate(links):
|
||||
original_link_info = original_links[link_index]
|
||||
|
||||
# Replace in the document text
|
||||
replacement_link = _construct_html_link(
|
||||
link_text=link["text"],
|
||||
attributes=original_link_info["attributes"],
|
||||
lang_code=lang_code,
|
||||
)
|
||||
line_no = link["line_no"] - 1
|
||||
modified_text[line_no] = modified_text[line_no].replace(
|
||||
link["full_tag"], replacement_link, 1
|
||||
)
|
||||
|
||||
return modified_text
|
||||
|
||||
|
||||
# Multiline code blocks
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def get_code_block_lang(line: str) -> str:
|
||||
match = CODE_BLOCK_LANG_RE.match(line)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return ""
|
||||
|
||||
|
||||
def extract_multiline_code_blocks(text: list[str]) -> list[MultilineCodeBlockInfo]:
|
||||
blocks: list[MultilineCodeBlockInfo] = []
|
||||
|
||||
in_code_block3 = False
|
||||
in_code_block4 = False
|
||||
current_block_lang = ""
|
||||
current_block_start_line = -1
|
||||
current_block_lines = []
|
||||
|
||||
for line_no, line in enumerate(text, start=1):
|
||||
stripped = line.lstrip()
|
||||
|
||||
# --- Detect opening fence ---
|
||||
if not (in_code_block3 or in_code_block4):
|
||||
if stripped.startswith("```"):
|
||||
current_block_start_line = line_no
|
||||
count = len(stripped) - len(stripped.lstrip("`"))
|
||||
if count == 3:
|
||||
in_code_block3 = True
|
||||
current_block_lang = get_code_block_lang(stripped)
|
||||
current_block_lines = [line]
|
||||
continue
|
||||
elif count >= 4:
|
||||
in_code_block4 = True
|
||||
current_block_lang = get_code_block_lang(stripped)
|
||||
current_block_lines = [line]
|
||||
continue
|
||||
|
||||
# --- Detect closing fence ---
|
||||
elif in_code_block3:
|
||||
if stripped.startswith("```"):
|
||||
count = len(stripped) - len(stripped.lstrip("`"))
|
||||
if count == 3:
|
||||
current_block_lines.append(line)
|
||||
blocks.append(
|
||||
MultilineCodeBlockInfo(
|
||||
lang=current_block_lang,
|
||||
start_line_no=current_block_start_line,
|
||||
content=current_block_lines,
|
||||
)
|
||||
)
|
||||
in_code_block3 = False
|
||||
current_block_lang = ""
|
||||
current_block_start_line = -1
|
||||
current_block_lines = []
|
||||
continue
|
||||
current_block_lines.append(line)
|
||||
|
||||
elif in_code_block4:
|
||||
if stripped.startswith("````"):
|
||||
count = len(stripped) - len(stripped.lstrip("`"))
|
||||
if count >= 4:
|
||||
current_block_lines.append(line)
|
||||
blocks.append(
|
||||
MultilineCodeBlockInfo(
|
||||
lang=current_block_lang,
|
||||
start_line_no=current_block_start_line,
|
||||
content=current_block_lines,
|
||||
)
|
||||
)
|
||||
in_code_block4 = False
|
||||
current_block_lang = ""
|
||||
current_block_start_line = -1
|
||||
current_block_lines = []
|
||||
continue
|
||||
current_block_lines.append(line)
|
||||
|
||||
return blocks
|
||||
|
||||
|
||||
def _split_hash_comment(line: str) -> tuple[str, str | None]:
|
||||
match = HASH_COMMENT_RE.match(line)
|
||||
if match:
|
||||
code = match.group("code").rstrip()
|
||||
comment = match.group("comment")
|
||||
return code, comment
|
||||
return line.rstrip(), None
|
||||
|
||||
|
||||
def _split_slashes_comment(line: str) -> tuple[str, str | None]:
|
||||
match = SLASHES_COMMENT_RE.match(line)
|
||||
if match:
|
||||
code = match.group("code").rstrip()
|
||||
comment = match.group("comment")
|
||||
return code, comment
|
||||
return line, None
|
||||
|
||||
|
||||
def replace_multiline_code_block(
|
||||
block_a: MultilineCodeBlockInfo, block_b: MultilineCodeBlockInfo
|
||||
) -> list[str]:
|
||||
"""
|
||||
Replace multiline code block `a` with block `b` leaving comments intact.
|
||||
|
||||
Syntax of comments depends on the language of the code block.
|
||||
Raises ValueError if the blocks are not compatible (different languages or different number of lines).
|
||||
"""
|
||||
|
||||
start_line = block_a["start_line_no"]
|
||||
end_line_no = start_line + len(block_a["content"]) - 1
|
||||
|
||||
if block_a["lang"] != block_b["lang"]:
|
||||
raise ValueError(
|
||||
f"Code block (lines {start_line}-{end_line_no}) "
|
||||
"has different language than the original block "
|
||||
f"('{block_a['lang']}' vs '{block_b['lang']}')"
|
||||
)
|
||||
if len(block_a["content"]) != len(block_b["content"]):
|
||||
raise ValueError(
|
||||
f"Code block (lines {start_line}-{end_line_no}) "
|
||||
"has different number of lines than the original block "
|
||||
f"({len(block_a['content'])} vs {len(block_b['content'])})"
|
||||
)
|
||||
|
||||
block_language = block_a["lang"].lower()
|
||||
if block_language in {"mermaid"}:
|
||||
if block_a != block_b:
|
||||
print(
|
||||
f"Skipping mermaid code block replacement (lines {start_line}-{end_line_no}). "
|
||||
"This should be checked manually."
|
||||
)
|
||||
return block_a["content"].copy() # We don't handle mermaid code blocks for now
|
||||
|
||||
code_block: list[str] = []
|
||||
for line_a, line_b in zip(block_a["content"], block_b["content"]):
|
||||
line_a_comment: str | None = None
|
||||
line_b_comment: str | None = None
|
||||
|
||||
# Handle comments based on language
|
||||
if block_language in {
|
||||
"python",
|
||||
"py",
|
||||
"sh",
|
||||
"bash",
|
||||
"dockerfile",
|
||||
"requirements",
|
||||
"gitignore",
|
||||
"toml",
|
||||
"yaml",
|
||||
"yml",
|
||||
"hash-style-comments",
|
||||
}:
|
||||
_line_a_code, line_a_comment = _split_hash_comment(line_a)
|
||||
_line_b_code, line_b_comment = _split_hash_comment(line_b)
|
||||
res_line = line_b
|
||||
if line_b_comment:
|
||||
res_line = res_line.replace(line_b_comment, line_a_comment, 1)
|
||||
code_block.append(res_line)
|
||||
elif block_language in {"console", "json", "slash-style-comments"}:
|
||||
_line_a_code, line_a_comment = _split_slashes_comment(line_a)
|
||||
_line_b_code, line_b_comment = _split_slashes_comment(line_b)
|
||||
res_line = line_b
|
||||
if line_b_comment:
|
||||
res_line = res_line.replace(line_b_comment, line_a_comment, 1)
|
||||
code_block.append(res_line)
|
||||
else:
|
||||
code_block.append(line_b)
|
||||
|
||||
return code_block
|
||||
|
||||
|
||||
def replace_multiline_code_blocks_in_text(
|
||||
text: list[str],
|
||||
code_blocks: list[MultilineCodeBlockInfo],
|
||||
original_code_blocks: list[MultilineCodeBlockInfo],
|
||||
) -> list[MultilineCodeBlockInfo]:
|
||||
"""
|
||||
Update each code block in `text` with the corresponding code block from
|
||||
`original_code_blocks` with comments taken from `code_blocks`.
|
||||
|
||||
Raises ValueError if the number, language, or shape of code blocks do not match.
|
||||
"""
|
||||
|
||||
if len(code_blocks) != len(original_code_blocks):
|
||||
raise ValueError(
|
||||
"Number of code blocks does not match the number in the original document "
|
||||
f"({len(code_blocks)} vs {len(original_code_blocks)})"
|
||||
)
|
||||
|
||||
modified_text = text.copy()
|
||||
for block, original_block in zip(code_blocks, original_code_blocks):
|
||||
updated_content = replace_multiline_code_block(block, original_block)
|
||||
|
||||
start_line_index = block["start_line_no"] - 1
|
||||
for i, updated_line in enumerate(updated_content):
|
||||
modified_text[start_line_index + i] = updated_line
|
||||
|
||||
return modified_text
|
||||
|
||||
|
||||
# All checks
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def check_translation(
|
||||
doc_lines: list[str],
|
||||
en_doc_lines: list[str],
|
||||
lang_code: str,
|
||||
auto_fix: bool,
|
||||
path: str,
|
||||
) -> list[str]:
|
||||
# Fix code includes
|
||||
en_code_includes = extract_code_includes(en_doc_lines)
|
||||
doc_lines_with_placeholders = replace_code_includes_with_placeholders(doc_lines)
|
||||
fixed_doc_lines = replace_placeholders_with_code_includes(
|
||||
doc_lines_with_placeholders, en_code_includes
|
||||
)
|
||||
if auto_fix and (fixed_doc_lines != doc_lines):
|
||||
print(f"Fixing code includes in: {path}")
|
||||
doc_lines = fixed_doc_lines
|
||||
|
||||
# Fix permalinks
|
||||
en_permalinks = extract_header_permalinks(en_doc_lines)
|
||||
doc_permalinks = extract_header_permalinks(doc_lines)
|
||||
fixed_doc_lines = replace_header_permalinks(
|
||||
doc_lines, doc_permalinks, en_permalinks
|
||||
)
|
||||
if auto_fix and (fixed_doc_lines != doc_lines):
|
||||
print(f"Fixing header permalinks in: {path}")
|
||||
doc_lines = fixed_doc_lines
|
||||
|
||||
# Fix markdown links
|
||||
en_markdown_links = extract_markdown_links(en_doc_lines)
|
||||
doc_markdown_links = extract_markdown_links(doc_lines)
|
||||
fixed_doc_lines = replace_markdown_links(
|
||||
doc_lines, doc_markdown_links, en_markdown_links, lang_code
|
||||
)
|
||||
if auto_fix and (fixed_doc_lines != doc_lines):
|
||||
print(f"Fixing markdown links in: {path}")
|
||||
doc_lines = fixed_doc_lines
|
||||
|
||||
# Fix HTML links
|
||||
en_html_links = extract_html_links(en_doc_lines)
|
||||
doc_html_links = extract_html_links(doc_lines)
|
||||
fixed_doc_lines = replace_html_links(
|
||||
doc_lines, doc_html_links, en_html_links, lang_code
|
||||
)
|
||||
if auto_fix and (fixed_doc_lines != doc_lines):
|
||||
print(f"Fixing HTML links in: {path}")
|
||||
doc_lines = fixed_doc_lines
|
||||
|
||||
# Fix multiline code blocks
|
||||
en_code_blocks = extract_multiline_code_blocks(en_doc_lines)
|
||||
doc_code_blocks = extract_multiline_code_blocks(doc_lines)
|
||||
fixed_doc_lines = replace_multiline_code_blocks_in_text(
|
||||
doc_lines, doc_code_blocks, en_code_blocks
|
||||
)
|
||||
if auto_fix and (fixed_doc_lines != doc_lines):
|
||||
print(f"Fixing multiline code blocks in: {path}")
|
||||
doc_lines = fixed_doc_lines
|
||||
|
||||
return doc_lines
|
||||
528
scripts/llm-general-prompt.md
Normal file
528
scripts/llm-general-prompt.md
Normal file
@@ -0,0 +1,528 @@
|
||||
### Your task
|
||||
|
||||
Translate an English original content to a target language.
|
||||
|
||||
The original content is written in Markdown, write the translation in Markdown as well.
|
||||
|
||||
The original content will be surrounded by triple percentage signs (%%%). Do not include the triple percentage signs in the translation.
|
||||
|
||||
### Technical terms in English
|
||||
|
||||
For technical terms in English that don't have a common translation term, use the original term in English.
|
||||
|
||||
### Content of code snippets
|
||||
|
||||
Do not translate the content of code snippets, keep the original in English. For example, `list`, `dict`, keep them as is.
|
||||
|
||||
### Content of code blocks
|
||||
|
||||
Do not translate the content of code blocks, except for comments in the language which the code block uses.
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English) - The code block is a bash code example with one comment:
|
||||
|
||||
```bash
|
||||
# Print greeting
|
||||
echo "Hello, World!"
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```bash
|
||||
# Gruß ausgeben
|
||||
echo "Hello, World!"
|
||||
```
|
||||
|
||||
Source (English) - The code block is a console example containing HTML tags. No comments, so nothing to change here:
|
||||
|
||||
```console
|
||||
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
|
||||
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server
|
||||
Searching for package file structure
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```console
|
||||
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
|
||||
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server
|
||||
Searching for package file structure
|
||||
```
|
||||
|
||||
Source (English) - The code block is a console example containing 5 comments:
|
||||
|
||||
|
||||
```console
|
||||
// Go to the home directory
|
||||
$ cd
|
||||
// Create a directory for all your code projects
|
||||
$ mkdir code
|
||||
// Enter into that code directory
|
||||
$ cd code
|
||||
// Create a directory for this project
|
||||
$ mkdir awesome-project
|
||||
// Enter into that project directory
|
||||
$ cd awesome-project
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```console
|
||||
// Gehe zum Home-Verzeichnis
|
||||
$ cd
|
||||
// Erstelle ein Verzeichnis für alle Ihre Code-Projekte
|
||||
$ mkdir code
|
||||
// Gehe in dieses Code-Verzeichnis
|
||||
$ cd code
|
||||
// Erstelle ein Verzeichnis für dieses Projekt
|
||||
$ mkdir awesome-project
|
||||
// Gehe in dieses Projektverzeichnis
|
||||
$ cd awesome-project
|
||||
```
|
||||
|
||||
If there is an existing translation and its Mermaid diagram is in sync with the Mermaid diagram in the English source, except a few translated words, then use the Mermaid diagram of the existing translation. The human editor of the translation translated these words in the Mermaid diagram. Keep these translations, do not revert them back to the English source.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[global env]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone project]
|
||||
stone(philosophers-stone) -->|requires| harry-1
|
||||
end
|
||||
```
|
||||
|
||||
Existing translation (German) - has three translations:
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[globale Umgebung]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone-Projekt]
|
||||
stone(philosophers-stone) -->|benötigt| harry-1
|
||||
end
|
||||
```
|
||||
|
||||
Result (German) - you change nothing:
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[globale Umgebung]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone-Projekt]
|
||||
stone(philosophers-stone) -->|benötigt| harry-1
|
||||
end
|
||||
```
|
||||
|
||||
### Special blocks
|
||||
|
||||
There are special blocks of notes, tips and others that look like:
|
||||
|
||||
/// note
|
||||
Here goes a note
|
||||
///
|
||||
|
||||
To translate it, keep the same line and add the translation after a vertical bar.
|
||||
|
||||
For example, if you were translating to Spanish, you would write:
|
||||
|
||||
/// note | Nota
|
||||
|
||||
Some examples in Spanish:
|
||||
|
||||
Source (English):
|
||||
|
||||
/// tip
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
/// tip | Consejo
|
||||
|
||||
Source (English):
|
||||
|
||||
/// details | Preview
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
/// details | Vista previa
|
||||
|
||||
### Tab blocks
|
||||
|
||||
There are special blocks surrounded by four slashes (////). They mark text, which will be rendered as part of a tab in the final document. The scheme is:
|
||||
|
||||
//// tab | {tab title}
|
||||
{tab content, may span many lines}
|
||||
////
|
||||
|
||||
Keep everything before the vertical bar (|) as is, including the vertical bar. Translate the tab title. Translate the tab content, applying the rules you know. Keep the four block closing slashes as is.
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
//// tab | Python 3.8+ non-Annotated
|
||||
Hello
|
||||
////
|
||||
|
||||
Result (German):
|
||||
|
||||
//// tab | Python 3.8+ nicht annotiert
|
||||
Hallo
|
||||
////
|
||||
|
||||
Source (English) - Here there is nothing to translate in the tab title:
|
||||
|
||||
//// tab | Linux, macOS, Windows Bash
|
||||
Hello again
|
||||
////
|
||||
|
||||
Result (German):
|
||||
|
||||
//// tab | Linux, macOS, Windows Bash
|
||||
Hallo wieder
|
||||
////
|
||||
|
||||
### Headings
|
||||
|
||||
Every Markdown heading in the English text (all levels) ends with a part inside curly brackets. This part denotes the hash of this heading, which is used in links to this heading. In translations, translate the heading, but do not translate this hash part, so that links do not break.
|
||||
|
||||
Examples of how to translate a heading:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
## Alternative API docs { #alternative-api-docs }
|
||||
```
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
```
|
||||
## Documentación de la API alternativa { #alternative-api-docs }
|
||||
```
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
### Example { #example }
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
### Beispiel { #example }
|
||||
```
|
||||
|
||||
### Links
|
||||
|
||||
Use the following rules for links (apply both to Markdown-style links ([text](url)) and to HTML-style <a href="url">text</a> tags):
|
||||
|
||||
- For relative URLs, only translate the link text. Do not translate the URL or its parts.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
[One of the fastest Python frameworks available](#performance)
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
[Eines der schnellsten verfügbaren Python-Frameworks](#performance)
|
||||
```
|
||||
|
||||
- For absolute URLs which DO NOT start EXACTLY with https://fastapi.tiangolo.com, only translate the link text and leave the URL unchanged.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel docs</a>
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
<a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel-Dokumentation</a>
|
||||
```
|
||||
|
||||
- For absolute URLs which DO start EXACTLY with https://fastapi.tiangolo.com, only translate the link text and change the URL by adding the language code (https://fastapi.tiangolo.com/{language_code}[rest part of the url]).
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<a href="https://fastapi.tiangolo.com/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentation</a>
|
||||
```
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
```
|
||||
<a href="https://fastapi.tiangolo.com/es/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentación</a>
|
||||
```
|
||||
|
||||
- Do not add language codes for URLs that point to static assets (e.g., images, CSS, JavaScript).
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Something</a>
|
||||
```
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
```
|
||||
<a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Algo</a>
|
||||
```
|
||||
|
||||
- For internal links, only translate link text.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
[Create Pull Requests](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
[Pull Requests erzeugen](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}
|
||||
```
|
||||
|
||||
- Do not translate anchor fragments in links (the part after `#`), as they must remain the same to work correctly.
|
||||
|
||||
- If an existing translation has a link with an anchor fragment different to the anchor fragment in the English source, then this is an error. Fix this by using the anchor fragment of the English source.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
[Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}
|
||||
```
|
||||
|
||||
Existing wrong translation (German) - notice the wrongly translated anchor fragment:
|
||||
|
||||
```
|
||||
[Body - Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#einzelne-werte-im-body){.internal-link target=_blank}.
|
||||
```
|
||||
|
||||
Result (German) - you fix the anchor fragment:
|
||||
|
||||
```
|
||||
[Body - Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}.
|
||||
```
|
||||
|
||||
- Do not add anchor fragments at will, even if this makes sense. If the English source has no anchor, don't add one.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
Create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}
|
||||
```
|
||||
|
||||
Wrong translation in German - Anchor added to the URL.
|
||||
|
||||
```
|
||||
Erstelle eine [virtuelle Umgebung](../virtual-environments.md#create-a-virtual-environment){.internal-link target=_blank}
|
||||
```
|
||||
|
||||
Good translation (German) - URL stays like in the English source.
|
||||
|
||||
```
|
||||
Erstelle eine [Virtuelle Umgebung](../virtual-environments.md){.internal-link target=_blank}
|
||||
```
|
||||
|
||||
### HTML abbr elements
|
||||
|
||||
Translate HTML abbr elements (`<abbr title="description">text</abbr>`) as follows:
|
||||
|
||||
- If the text surrounded by the abbr element is an abbreviation (the text may be surrounded by further HTML or Markdown markup or quotes, for example <code>text</code> or `text` or "text", ignore that further markup when deciding if the text is an abbreviation), and if the description (the text inside the title attribute) contains the full phrase for this abbreviation, then append a dash (-) to the full phrase, followed by the translation of the full phrase.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="{full phrase}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
<abbr title="{full phrase} - {translation of full phrase}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="Internet of Things">IoT</abbr>
|
||||
<abbr title="Central Processing Unit">CPU</abbr>
|
||||
<abbr title="too long; didn't read"><strong>TL;DR:</strong></abbr>
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
<abbr title="Internet of Things - Internet der Dinge">IoT</abbr>
|
||||
<abbr title="Central Processing Unit - Zentrale Verarbeitungseinheit">CPU</abbr>
|
||||
<abbr title="too long; didn't read - zu lang; hab's nicht gelesen"><strong>TL;DR:</strong></abbr>
|
||||
```
|
||||
|
||||
- If the language to which you translate mostly uses the letters of the ASCII char set (for example Spanish, French, German, but not Russian, Chinese) and if the translation of the full phrase is identical to, or starts with the same letters as the original full phrase, then only give the translation of the full phrase.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="{full phrase}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
<abbr title="{translation of full phrase}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="JSON Web Tokens">JWT</abbr>
|
||||
<abbr title="Enumeration">Enum</abbr>
|
||||
<abbr title="Asynchronous Server Gateway Interface">ASGI</abbr>
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
<abbr title="JSON Web Tokens">JWT</abbr>
|
||||
<abbr title="Enumeration">Enum</abbr>
|
||||
<abbr title="Asynchrones Server-Gateway-Interface">ASGI</abbr>
|
||||
```
|
||||
|
||||
- If the description is not a full phrase for an abbreviation which the abbr element surrounds, but some other information, then just translate the description.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="{description}">{text}</abbr>
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
<abbr title="{translation of description}">{translation of text}</abbr>
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="also known as: endpoints, routes">path</abbr>
|
||||
<abbr title="a program that checks for code errors">linter</abbr>
|
||||
<abbr title="converting the string that comes from an HTTP request into Python data">parsing</abbr>
|
||||
<abbr title="before 2023-03">0.95.0</abbr>
|
||||
<abbr title="2023-08-26">at the time of writing this</abbr>
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
<abbr title="auch bekannt als: Endpunkte, Routen">Pfad</abbr>
|
||||
<abbr title="Programm das auf Fehler im Code prüft">Linter</abbr>
|
||||
<abbr title="Konvertieren des Strings eines HTTP-Requests in Python-Daten">Parsen</abbr>
|
||||
<abbr title="vor 2023-03">0.95.0</abbr>
|
||||
<abbr title="2023-08-26">zum Zeitpunkt als das hier geschrieben wurde</abbr>
|
||||
```
|
||||
|
||||
- If the text surrounded by the abbr element is an abbreviation and the description contains both the full phrase for that abbreviation, and other information, separated by a colon (`:`), then append a dash (`-`) and the translation of the full phrase to the original full phrase and translate the other information.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="{full phrase}: {other information}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
<abbr title="{full phrase} - {translation of full phrase}: {translation of other information}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="Input/Output: disk reading or writing, network communication.">I/O</abbr>
|
||||
<abbr title="Content Delivery Network: service, that provides static files.">CDN</abbr>
|
||||
<abbr title="Integrated Development Environment: similar to a code editor">IDE</abbr>
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
<abbr title="Input/Output - Eingabe/Ausgabe: Lesen oder Schreiben auf der Festplatte, Netzwerkkommunikation.">I/O</abbr>
|
||||
<abbr title="Content Delivery Network - Inhalte auslieferndes Netzwerk: Dienst, der statische Dateien bereitstellt.">CDN</abbr>
|
||||
<abbr title="Integrated Development Environment - Integrierte Entwicklungsumgebung: Ähnlich einem Code-Editor">IDE</abbr>
|
||||
```
|
||||
|
||||
- You can leave the original full phrase away, if the translated full phrase is identical or starts with the same letters as the original full phrase.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="{full phrase}: {information}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```
|
||||
<abbr title="{translation of full phrase}: {translation of information}">{abbreviation}</abbr>
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
```
|
||||
<abbr title="Object Relational Mapper: a fancy term for a library where some classes represent SQL tables and instances represent rows in those tables">ORM</abbr>
|
||||
```
|
||||
|
||||
Result (German):
|
||||
|
||||
```
|
||||
<abbr title="Objektrelationaler Mapper: Ein Fachbegriff für eine Bibliothek, in der einige Klassen SQL-Tabellen und Instanzen Zeilen in diesen Tabellen darstellen">ORM</abbr>
|
||||
```
|
||||
|
||||
- If there is an existing translation, and it has ADDITIONAL abbr elements in a sentence, and these additional abbr elements do not exist in the related sentence in the English text, then KEEP those additional abbr elements in the translation. Do not remove them. Except when you remove the whole sentence from the translation, because the whole sentence was removed from the English text, then also remove the abbr element. The reasoning for this rule is, that such additional abbr elements are manually added by the human editor of the translation, in order to translate or explain an English word to the human readers of the translation. These additional abbr elements would not make sense in the English text, but they do make sense in the translation. So keep them in the translation, even though they are not part of the English text. This rule only applies to abbr elements.
|
||||
|
||||
- Apply above rules also when there is an existing translation! Make sure that all title attributes in abbr elements get properly translated or updated, using the schemes given above. However, leave the ADDITIONAL abbr's described above alone. Do not change their formatting or content.
|
||||
32
scripts/tests/test_translation_fixer/conftest.py
Normal file
32
scripts/tests/test_translation_fixer/conftest.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
|
||||
@pytest.fixture(name="runner")
|
||||
def get_runner():
|
||||
runner = CliRunner()
|
||||
with runner.isolated_filesystem():
|
||||
yield runner
|
||||
|
||||
|
||||
@pytest.fixture(name="root_dir")
|
||||
def prepare_paths(runner):
|
||||
docs_dir = Path("docs")
|
||||
en_docs_dir = docs_dir / "en" / "docs"
|
||||
lang_docs_dir = docs_dir / "lang" / "docs"
|
||||
en_docs_dir.mkdir(parents=True, exist_ok=True)
|
||||
lang_docs_dir.mkdir(parents=True, exist_ok=True)
|
||||
yield Path.cwd()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def copy_test_files(root_dir: Path, request: pytest.FixtureRequest):
|
||||
en_file_path = Path(request.param[0])
|
||||
translation_file_path = Path(request.param[1])
|
||||
shutil.copy(str(en_file_path), str(root_dir / "docs" / "en" / "docs" / "doc.md"))
|
||||
shutil.copy(
|
||||
str(translation_file_path), str(root_dir / "docs" / "lang" / "docs" / "doc.md")
|
||||
)
|
||||
@@ -0,0 +1,44 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
```toml
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Mermaid diagram
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,45 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
```toml
|
||||
# Extra line
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,45 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
The following block is missing first line:
|
||||
|
||||
```toml
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
```toml
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,44 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
```toml
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|требует| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,50 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
```toml
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
Extra code block
|
||||
|
||||
```
|
||||
$ cd my_project
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,41 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
Missing code block...
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,46 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
The following block has wrong language code (should be TOML):
|
||||
|
||||
```yaml
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,46 @@
|
||||
# Code blocks { #code-blocks }
|
||||
|
||||
Some text
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
Some more text
|
||||
|
||||
The following block has wrong language code (should be TOML):
|
||||
|
||||
```
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
And more text
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
And even more text
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
Диаграма Mermaid
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
@@ -0,0 +1,58 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_code_blocks/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_lines_number_gt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_lines_number_gt.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Code block (lines 14-18) has different number of lines than the original block (5 vs 4)"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_lines_number_lt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
# assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_lines_number_lt.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Code block (lines 16-18) has different number of lines than the original block (3 vs 4)"
|
||||
) in result.output
|
||||
@@ -0,0 +1,59 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_code_blocks/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_mermaid_translated.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_translated(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_mermaid_translated.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert (
|
||||
"Skipping mermaid code block replacement (lines 41-44). This should be checked manually."
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[
|
||||
(
|
||||
f"{data_path}/en_doc.md",
|
||||
f"{data_path}/translated_doc_mermaid_not_translated.md",
|
||||
)
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
def test_not_translated(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_mermaid_not_translated.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert ("Skipping mermaid code block replacement") not in result.output
|
||||
@@ -0,0 +1,56 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_code_blocks/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_gt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of code blocks does not match the number "
|
||||
"in the original document (6 vs 5)"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_lt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
# assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of code blocks does not match the number "
|
||||
"in the original document (4 vs 5)"
|
||||
) in result.output
|
||||
@@ -0,0 +1,58 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_code_blocks/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_wrong_lang_code.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_wrong_lang_code_1(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_wrong_lang_code.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Code block (lines 16-19) has different language than the original block ('yaml' vs 'toml')"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_wrong_lang_code_2.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_wrong_lang_code_2(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_wrong_lang_code_2.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Code block (lines 16-19) has different language than the original block ('' vs 'toml')"
|
||||
) in result.output
|
||||
@@ -0,0 +1,13 @@
|
||||
# Header
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
Some text
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
Some more text
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *}
|
||||
|
||||
And even more text
|
||||
@@ -0,0 +1,15 @@
|
||||
# Header
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
Some text
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
Some more text
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *}
|
||||
|
||||
And even more text
|
||||
|
||||
{* ../../docs_src/python_types/tutorial001_py39.py *}
|
||||
@@ -0,0 +1,13 @@
|
||||
# Header
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
Some text
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
Some more text
|
||||
|
||||
...
|
||||
|
||||
And even more text
|
||||
@@ -0,0 +1,56 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_code_includes/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_gt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of code include placeholders does not match the number of code includes "
|
||||
"in the original document (4 vs 3)"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_lt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of code include placeholders does not match the number of code includes "
|
||||
"in the original document (2 vs 3)"
|
||||
) in result.output
|
||||
@@ -0,0 +1,244 @@
|
||||
# Test translation fixer tool { #test-translation-fixer }
|
||||
|
||||
## Code blocks with and without comments { #code-blocks-with-and-without-comments }
|
||||
|
||||
This is a test page for the translation fixer tool.
|
||||
|
||||
### Code blocks with comments { #code-blocks-with-comments }
|
||||
|
||||
The following code blocks include comments in different styles.
|
||||
Fixer tool should fix content, but preserve comments correctly.
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
# Comment with indentation
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
```toml
|
||||
# This is a sample TOML code block
|
||||
title = "TOML Example" # Title of the document
|
||||
```
|
||||
|
||||
```console
|
||||
// Use the command "live" and pass the language code as a CLI argument
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
// This is a sample JSON code block
|
||||
"greeting": "Hello, world!" // Greeting
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Code blocks with comments where language uses different comment styles { #code-blocks-with-different-comment-styles }
|
||||
|
||||
The following code blocks include comments in different styles based on the language.
|
||||
Fixer tool will not preserve comments in these blocks.
|
||||
|
||||
```json
|
||||
{
|
||||
# This is a sample JSON code block
|
||||
"greeting": "Hello, world!" # Print greeting
|
||||
}
|
||||
```
|
||||
|
||||
```console
|
||||
# This is a sample console code block
|
||||
$ echo "Hello, world!" # Print greeting
|
||||
```
|
||||
|
||||
```toml
|
||||
// This is a sample TOML code block
|
||||
title = "TOML Example" // Title of the document
|
||||
```
|
||||
|
||||
|
||||
### Code blocks with comments with unsupported languages or without language specified { #code-blocks-with-unsupported-languages }
|
||||
|
||||
The following code blocks use unsupported languages for comment preservation.
|
||||
Fixer tool will not preserve comments in these blocks.
|
||||
|
||||
```javascript
|
||||
// This is a sample JavaScript code block
|
||||
console.log("Hello, world!"); // Print greeting
|
||||
```
|
||||
|
||||
```
|
||||
# This is a sample console code block
|
||||
$ echo "Hello, world!" # Print greeting
|
||||
```
|
||||
|
||||
```
|
||||
// This is a sample console code block
|
||||
$ echo "Hello, world!" // Print greeting
|
||||
```
|
||||
|
||||
|
||||
### Code blocks with comments that don't follow pattern { #code-blocks-with-comments-without-pattern }
|
||||
|
||||
Fixer tool expects comments that follow specific pattern:
|
||||
|
||||
- For hash-style comments: comment starts with `# ` (hash following by whitespace) in the beginning of the string or after a whitespace.
|
||||
- For slash-style comments: comment starts with `// ` (two slashes following by whitespace) in the beginning of the string or after a whitespace.
|
||||
|
||||
If comment doesn't follow this pattern, fixer tool will not preserve it.
|
||||
|
||||
```python
|
||||
#Function declaration
|
||||
def hello_world():# Print greeting
|
||||
print("Hello, world!") #Print greeting without space after hash
|
||||
```
|
||||
|
||||
```console
|
||||
//Function declaration
|
||||
def hello_world():// Print greeting
|
||||
print("Hello, world!") //Print greeting without space after slashes
|
||||
```
|
||||
|
||||
## Code blocks with quadruple backticks { #code-blocks-with-quadruple-backticks }
|
||||
|
||||
The following code block uses quadruple backticks.
|
||||
|
||||
````python
|
||||
# Hello world function
|
||||
def hello_world():
|
||||
print("Hello, world!") # Print greeting
|
||||
````
|
||||
|
||||
### Backticks number mismatch is fixable { #backticks-number-mismatch-is-fixable }
|
||||
|
||||
The following code block has triple backticks in the original document, but quadruple backticks in the translated document.
|
||||
It will be fixed by the fixer tool (will convert to triple backticks).
|
||||
|
||||
```Python
|
||||
# Some Python code
|
||||
```
|
||||
|
||||
### Triple backticks inside quadruple backticks { #triple-backticks-inside-quadruple-backticks }
|
||||
|
||||
Comments inside nested code block will NOT be preserved.
|
||||
|
||||
````
|
||||
Here is a code block with quadruple backticks that contains triple backticks inside:
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
# Code includes { #code-includes }
|
||||
|
||||
## Simple code includes { #simple-code-includes }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial001_py39.py *}
|
||||
|
||||
{* ../../docs_src/python_types/tutorial002_py39.py *}
|
||||
|
||||
|
||||
## Code includes with highlighting { #code-includes-with-highlighting }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial002_py39.py hl[1] *}
|
||||
|
||||
{* ../../docs_src/python_types/tutorial006_py39.py hl[10] *}
|
||||
|
||||
|
||||
## Code includes with line ranges { #code-includes-with-line-ranges }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] *}
|
||||
|
||||
|
||||
## Code includes with line ranges and highlighting { #code-includes-with-line-ranges-and-highlighting }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial015_an_py310.py ln[10:15] hl[12:14] *}
|
||||
|
||||
|
||||
## Code includes qith title { #code-includes-with-title }
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/routers/users.py hl[1,3] title["app/routers/users.py"] *}
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
## Code includes with unknown attributes { #code-includes-with-unknown-attributes }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial001_py39.py unknown[123] *}
|
||||
|
||||
## Some more code includes to test fixing { #some-more-code-includes-to-test-fixing }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *}
|
||||
|
||||
|
||||
|
||||
# Links { #links }
|
||||
|
||||
## Markdown-style links { #markdown-style-links }
|
||||
|
||||
This is a [Markdown link](https://example.com) to an external site.
|
||||
|
||||
This is a link with attributes: [**FastAPI** Project Generators](project-generation.md){.internal-link target=_blank}
|
||||
|
||||
This is a link to the main FastAPI site: [FastAPI](https://fastapi.tiangolo.com) - tool should add language code to the URL.
|
||||
|
||||
This is a link to one of the pages on FastAPI site: [How to](https://fastapi.tiangolo.com/how-to/) - tool should add language code to the URL.
|
||||
|
||||
Link to test wrong attribute: [**FastAPI** Project Generators](project-generation.md){.internal-link} - tool should fix the attribute.
|
||||
|
||||
Link with a title: [Example](https://example.com "Example site") - URL will be fixed, title preserved.
|
||||
|
||||
### Markdown link to static assets { #markdown-link-to-static-assets }
|
||||
|
||||
These are links to static assets:
|
||||
|
||||
* [FastAPI Logo](https://fastapi.tiangolo.com/img/fastapi-logo.png)
|
||||
* [FastAPI CSS](https://fastapi.tiangolo.com/css/fastapi.css)
|
||||
* [FastAPI JS](https://fastapi.tiangolo.com/js/fastapi.js)
|
||||
|
||||
Tool should NOT add language code to their URLs.
|
||||
|
||||
## HTML-style links { #html-style-links }
|
||||
|
||||
This is an <a href="https://example.com" target="_blank" class="external-link">HTML link</a> to an external site.
|
||||
|
||||
This is an <a href="https://fastapi.tiangolo.com">link to the main FastAPI site</a> - tool should add language code to the URL.
|
||||
|
||||
This is an <a href="https://fastapi.tiangolo.com/how-to/">link to one of the pages on FastAPI site</a> - tool should add language code to the URL.
|
||||
|
||||
Link to test wrong attribute: <a href="project-generation.md" class="internal-link">**FastAPI** Project Generators</a> - tool should fix the attribute.
|
||||
|
||||
### HTML links to static assets { #html-links-to-static-assets }
|
||||
|
||||
These are links to static assets:
|
||||
|
||||
* <a href="https://fastapi.tiangolo.com/img/fastapi-logo.png">FastAPI Logo</a>
|
||||
* <a href="https://fastapi.tiangolo.com/css/fastapi.css">FastAPI CSS</a>
|
||||
* <a href="https://fastapi.tiangolo.com/js/fastapi.js">FastAPI JS</a>
|
||||
|
||||
Tool should NOT add language code to their URLs.
|
||||
|
||||
# Header (with HTML link to <a href="https://tiangolo.com">tiangolo.com</a>) { #header-with-html-link-to-tiangolo-com }
|
||||
|
||||
#Not a header
|
||||
|
||||
```Python
|
||||
# Also not a header
|
||||
```
|
||||
|
||||
Some text
|
||||
@@ -0,0 +1,240 @@
|
||||
# Тестовый инструмент исправления переводов { #test-translation-fixer }
|
||||
|
||||
## Блоки кода с комментариями и без комментариев { #code-blocks-with-and-without-comments }
|
||||
|
||||
Это тестовая страница для инструмента исправления переводов.
|
||||
|
||||
### Блоки кода с комментариями { #code-blocks-with-comments }
|
||||
|
||||
Следующие блоки кода содержат комментарии в разных стилях.
|
||||
Инструмент исправления должен исправлять содержимое, но корректно сохранять комментарии.
|
||||
|
||||
```python
|
||||
# Это пример блока кода на Python
|
||||
def hello_world():
|
||||
# Комментарий с отступом
|
||||
print("Hello, world!") # Печать приветствия
|
||||
```
|
||||
|
||||
```toml
|
||||
# Это пример блока кода на TOML
|
||||
title = "TOML Example" # Заголовок документа
|
||||
```
|
||||
|
||||
```console
|
||||
// Используйте команду "live" и передайте код языка в качестве аргумента CLI
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
// Это пример блока кода на JSON
|
||||
"greeting": "Hello, world!" // Печать приветствия
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Блоки кода с комментариями, где язык использует другие стили комментариев { #code-blocks-with-different-comment-styles }
|
||||
|
||||
Следующие блоки кода содержат комментарии в разных стилях в зависимости от языка.
|
||||
Инструмент исправления не будет сохранять комментарии в этих блоках.
|
||||
|
||||
```json
|
||||
{
|
||||
# Это пример блока кода на JSON
|
||||
"greeting": "Hello, world!" # Печать приветствия
|
||||
}
|
||||
```
|
||||
|
||||
```console
|
||||
# Это пример блока кода консоли
|
||||
$ echo "Hello, world!" # Печать приветствия
|
||||
```
|
||||
|
||||
```toml
|
||||
// Это пример блока кода на TOML
|
||||
title = "TOML Example" // Заголовок документа
|
||||
```
|
||||
|
||||
### Блоки кода с комментариями на неподдерживаемых языках или без указания языка { #code-blocks-with-unsupported-languages }
|
||||
|
||||
Следующие блоки кода используют неподдерживаемые языки для сохранения комментариев.
|
||||
Инструмент исправления не будет сохранять комментарии в этих блоках.
|
||||
|
||||
```javascript
|
||||
// Это пример блока кода на JavaScript
|
||||
console.log("Hello, world!"); // Печать приветствия
|
||||
```
|
||||
|
||||
```
|
||||
# Это пример блока кода консоли
|
||||
$ echo "Hello, world!" # Печать приветствия
|
||||
```
|
||||
|
||||
```
|
||||
// Это пример блока кода консоли
|
||||
$ echo "Hello, world!" // Печать приветствия
|
||||
```
|
||||
|
||||
### Блоки кода с комментариями, которые не соответствуют шаблону { #code-blocks-with-comments-without-pattern }
|
||||
|
||||
Инструмент исправления ожидает комментарии, которые соответствуют определённому шаблону:
|
||||
|
||||
- Для комментариев в стиле с решёткой: комментарий начинается с `# ` (решётка, затем пробел) в начале строки или после пробела.
|
||||
- Для комментариев в стиле со слешами: комментарий начинается с `// ` (два слеша, затем пробел) в начале строки или после пробела.
|
||||
|
||||
Если комментарий не соответствует этому шаблону, инструмент исправления не будет его сохранять.
|
||||
|
||||
```python
|
||||
#Объявление функции
|
||||
def hello_world():# Печать приветствия
|
||||
print("Hello, world!") #Печать приветствия без пробела после решётки
|
||||
```
|
||||
|
||||
```console
|
||||
//Объявление функции
|
||||
def hello_world():// Печать приветствия
|
||||
print("Hello, world!") //Печать приветствия без пробела после слешей
|
||||
```
|
||||
|
||||
## Блок кода с четырёхкратными обратными кавычками { #code-blocks-with-quadruple-backticks }
|
||||
|
||||
Следующий блок кода содержит четырёхкратные обратные кавычки.
|
||||
|
||||
````python
|
||||
# Функция приветствия
|
||||
def hello_world():
|
||||
print("Hello, world") # Печать приветствия
|
||||
````
|
||||
|
||||
### Несоответствие обратных кавычек фиксится { #backticks-number-mismatch-is-fixable }
|
||||
|
||||
Следующий блок кода имеет тройные обратные кавычки в оригинальном документе, но четырёхкратные обратные кавычки в переведённом документе.
|
||||
Это будет исправлено инструментом исправления (будет преобразовано в тройные обратные кавычки).
|
||||
|
||||
````Python
|
||||
# Немного кода на Python
|
||||
````
|
||||
|
||||
### Блок кода в тройных обратных кавычка внутри блока кода в четырёхкратных обратных кавычках { #triple-backticks-inside-quadruple-backticks }
|
||||
|
||||
Комментарии внутри вложенного блока кода в тройных обратных кавычках НЕ БУДУТ сохранены.
|
||||
|
||||
````
|
||||
Here is a code block with quadruple backticks that contains triple backticks inside:
|
||||
|
||||
```python
|
||||
# Этот комментарий НЕ будет сохранён
|
||||
def hello_world():
|
||||
print("Hello, world") # Как и этот комментарий
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
# Включения кода { #code-includes }
|
||||
|
||||
## Простые включения кода { #simple-code-includes }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial001_py39.py *}
|
||||
|
||||
{* ../../docs_src/python_types/tutorial002_py39.py *}
|
||||
|
||||
|
||||
## Включения кода с подсветкой { #code-includes-with-highlighting }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial002_py39.py hl[1] *}
|
||||
|
||||
{* ../../docs_src/python_types/tutorial006_py39.py hl[10] *}
|
||||
|
||||
|
||||
## Включения кода с диапазонами строк { #code-includes-with-line-ranges }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] *}
|
||||
|
||||
|
||||
## Включения кода с диапазонами строк и подсветкой { #code-includes-with-line-ranges-and-highlighting }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial015_an_py310.py ln[10:15] hl[12:14] *}
|
||||
|
||||
|
||||
## Включения кода с заголовком { #code-includes-with-title }
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/routers/users.py hl[1,3] title["app/routers/users.py"] *}
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
## Включения кода с неизвестными атрибутами { #code-includes-with-unknown-attributes }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial001_py39.py unknown[123] *}
|
||||
|
||||
## Ещё включения кода для тестирования исправления { #some-more-code-includes-to-test-fixing }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19 : 21] *}
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/wrong.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[1:30] hl[1:10] *}
|
||||
|
||||
# Ссылки { #links }
|
||||
|
||||
## Ссылки в стиле Markdown { #markdown-style-links }
|
||||
|
||||
Это [Markdown-ссылка](https://example.com) на внешний сайт.
|
||||
|
||||
Это ссылка с атрибутами: [**FastAPI** генераторы проектов](project-generation.md){.internal-link target=_blank}
|
||||
|
||||
Это ссылка на основной сайт FastAPI: [FastAPI](https://fastapi.tiangolo.com) — инструмент должен добавить код языка в URL.
|
||||
|
||||
Это ссылка на одну из страниц на сайте FastAPI: [How to](https://fastapi.tiangolo.com/how-to) — инструмент должен добавить код языка в URL.
|
||||
|
||||
Ссылка для тестирования неправильного атрибута: [**FastAPI** генераторы проектов](project-generation.md){.external-link} - инструмент должен исправить атрибут.
|
||||
|
||||
Ссылка с заголовком: [Пример](http://example.com/ "Сайт для примера") - URL будет исправлен инструментом, заголовок сохранится.
|
||||
|
||||
### Markdown ссылки на статические ресурсы { #markdown-link-to-static-assets }
|
||||
|
||||
Это ссылки на статические ресурсы:
|
||||
|
||||
* [FastAPI Logo](https://fastapi.tiangolo.com/img/fastapi-logo.png)
|
||||
* [FastAPI CSS](https://fastapi.tiangolo.com/css/fastapi.css)
|
||||
* [FastAPI JS](https://fastapi.tiangolo.com/js/fastapi.js)
|
||||
|
||||
Инструмент НЕ должен добавлять код языка в их URL.
|
||||
|
||||
## Ссылки в стиле HTML { #html-style-links }
|
||||
|
||||
Это <a href="https://example.com" target="_blank" class="external-link">HTML-ссылка</a> на внешний сайт.
|
||||
|
||||
Это <a href="https://fastapi.tiangolo.com">ссылка на основной сайт FastAPI</a> — инструмент должен добавить код языка в URL.
|
||||
|
||||
Это <a href="https://fastapi.tiangolo.com/how-to/">ссылка на одну из страниц на сайте FastAPI</a> — инструмент должен добавить код языка в URL.
|
||||
|
||||
Ссылка для тестирования неправильного атрибута: <a href="project-generation.md" class="external-link">**FastAPI** генераторы проектов</a> - инструмент должен исправить атрибут.
|
||||
|
||||
### HTML ссылки на статические ресурсы { #html-links-to-static-assets }
|
||||
|
||||
Это ссылки на статические ресурсы:
|
||||
|
||||
* <a href="https://fastapi.tiangolo.com/img/fastapi-logo.png">FastAPI Logo</a>
|
||||
* <a href="https://fastapi.tiangolo.com/css/fastapi.css">FastAPI CSS</a>
|
||||
* <a href="https://fastapi.tiangolo.com/js/fastapi.js">FastAPI JS</a>
|
||||
|
||||
Инструмент НЕ должен добавлять код языка в их URL.
|
||||
|
||||
# Заголовок (с HTML ссылкой на <a href="https://tiangolo.com">tiangolo.com</a>) { #header-5 }
|
||||
|
||||
#Не заголовок
|
||||
|
||||
```Python
|
||||
# Также не заголовок
|
||||
```
|
||||
|
||||
Немного текста
|
||||
@@ -0,0 +1,240 @@
|
||||
# Тестовый инструмент исправления переводов { #test-translation-fixer }
|
||||
|
||||
## Блоки кода с комментариями и без комментариев { #code-blocks-with-and-without-comments }
|
||||
|
||||
Это тестовая страница для инструмента исправления переводов.
|
||||
|
||||
### Блоки кода с комментариями { #code-blocks-with-comments }
|
||||
|
||||
Следующие блоки кода содержат комментарии в разных стилях.
|
||||
Инструмент исправления должен исправлять содержимое, но корректно сохранять комментарии.
|
||||
|
||||
```python
|
||||
# Это пример блока кода на Python
|
||||
def hello_world():
|
||||
# Комментарий с отступом
|
||||
print("Hello, world!") # Печать приветствия
|
||||
```
|
||||
|
||||
```toml
|
||||
# Это пример блока кода на TOML
|
||||
title = "TOML Example" # Заголовок документа
|
||||
```
|
||||
|
||||
```console
|
||||
// Используйте команду "live" и передайте код языка в качестве аргумента CLI
|
||||
$ python ./scripts/docs.py live es
|
||||
|
||||
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
|
||||
<span style="color: green;">[INFO]</span> Start watching changes
|
||||
<span style="color: green;">[INFO]</span> Start detecting changes
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
// Это пример блока кода на JSON
|
||||
"greeting": "Hello, world!" // Печать приветствия
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Блоки кода с комментариями, где язык использует другие стили комментариев { #code-blocks-with-different-comment-styles }
|
||||
|
||||
Следующие блоки кода содержат комментарии в разных стилях в зависимости от языка.
|
||||
Инструмент исправления не будет сохранять комментарии в этих блоках.
|
||||
|
||||
```json
|
||||
{
|
||||
# This is a sample JSON code block
|
||||
"greeting": "Hello, world!" # Print greeting
|
||||
}
|
||||
```
|
||||
|
||||
```console
|
||||
# This is a sample console code block
|
||||
$ echo "Hello, world!" # Print greeting
|
||||
```
|
||||
|
||||
```toml
|
||||
// This is a sample TOML code block
|
||||
title = "TOML Example" // Title of the document
|
||||
```
|
||||
|
||||
### Блоки кода с комментариями на неподдерживаемых языках или без указания языка { #code-blocks-with-unsupported-languages }
|
||||
|
||||
Следующие блоки кода используют неподдерживаемые языки для сохранения комментариев.
|
||||
Инструмент исправления не будет сохранять комментарии в этих блоках.
|
||||
|
||||
```javascript
|
||||
// This is a sample JavaScript code block
|
||||
console.log("Hello, world!"); // Print greeting
|
||||
```
|
||||
|
||||
```
|
||||
# This is a sample console code block
|
||||
$ echo "Hello, world!" # Print greeting
|
||||
```
|
||||
|
||||
```
|
||||
// This is a sample console code block
|
||||
$ echo "Hello, world!" // Print greeting
|
||||
```
|
||||
|
||||
### Блоки кода с комментариями, которые не соответствуют шаблону { #code-blocks-with-comments-without-pattern }
|
||||
|
||||
Инструмент исправления ожидает комментарии, которые соответствуют определённому шаблону:
|
||||
|
||||
- Для комментариев в стиле с решёткой: комментарий начинается с `# ` (решётка, затем пробел) в начале строки или после пробела.
|
||||
- Для комментариев в стиле со слешами: комментарий начинается с `// ` (два слеша, затем пробел) в начале строки или после пробела.
|
||||
|
||||
Если комментарий не соответствует этому шаблону, инструмент исправления не будет его сохранять.
|
||||
|
||||
```python
|
||||
#Function declaration
|
||||
def hello_world():# Print greeting
|
||||
print("Hello, world!") #Print greeting without space after hash
|
||||
```
|
||||
|
||||
```console
|
||||
//Function declaration
|
||||
def hello_world():// Print greeting
|
||||
print("Hello, world!") //Print greeting without space after slashes
|
||||
```
|
||||
|
||||
## Блок кода с четырёхкратными обратными кавычками { #code-blocks-with-quadruple-backticks }
|
||||
|
||||
Следующий блок кода содержит четырёхкратные обратные кавычки.
|
||||
|
||||
````python
|
||||
# Функция приветствия
|
||||
def hello_world():
|
||||
print("Hello, world!") # Печать приветствия
|
||||
````
|
||||
|
||||
### Несоответствие обратных кавычек фиксится { #backticks-number-mismatch-is-fixable }
|
||||
|
||||
Следующий блок кода имеет тройные обратные кавычки в оригинальном документе, но четырёхкратные обратные кавычки в переведённом документе.
|
||||
Это будет исправлено инструментом исправления (будет преобразовано в тройные обратные кавычки).
|
||||
|
||||
```Python
|
||||
# Немного кода на Python
|
||||
```
|
||||
|
||||
### Блок кода в тройных обратных кавычка внутри блока кода в четырёхкратных обратных кавычках { #triple-backticks-inside-quadruple-backticks }
|
||||
|
||||
Комментарии внутри вложенного блока кода в тройных обратных кавычках НЕ БУДУТ сохранены.
|
||||
|
||||
````
|
||||
Here is a code block with quadruple backticks that contains triple backticks inside:
|
||||
|
||||
```python
|
||||
# This is a sample Python code block
|
||||
def hello_world():
|
||||
print("Hello, world!") # Print greeting
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
# Включения кода { #code-includes }
|
||||
|
||||
## Простые включения кода { #simple-code-includes }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial001_py39.py *}
|
||||
|
||||
{* ../../docs_src/python_types/tutorial002_py39.py *}
|
||||
|
||||
|
||||
## Включения кода с подсветкой { #code-includes-with-highlighting }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial002_py39.py hl[1] *}
|
||||
|
||||
{* ../../docs_src/python_types/tutorial006_py39.py hl[10] *}
|
||||
|
||||
|
||||
## Включения кода с диапазонами строк { #code-includes-with-line-ranges }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] *}
|
||||
|
||||
|
||||
## Включения кода с диапазонами строк и подсветкой { #code-includes-with-line-ranges-and-highlighting }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial015_an_py310.py ln[10:15] hl[12:14] *}
|
||||
|
||||
|
||||
## Включения кода с заголовком { #code-includes-with-title }
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/routers/users.py hl[1,3] title["app/routers/users.py"] *}
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
## Включения кода с неизвестными атрибутами { #code-includes-with-unknown-attributes }
|
||||
|
||||
{* ../../docs_src/python_types/tutorial001_py39.py unknown[123] *}
|
||||
|
||||
## Ещё включения кода для тестирования исправления { #some-more-code-includes-to-test-fixing }
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[19:21] *}
|
||||
|
||||
{* ../../docs_src/bigger_applications/app_an_py39/internal/admin.py hl[3] title["app/internal/admin.py"] *}
|
||||
|
||||
{* ../../docs_src/dependencies/tutorial013_an_py310.py ln[30:38] hl[31:33] *}
|
||||
|
||||
# Ссылки { #links }
|
||||
|
||||
## Ссылки в стиле Markdown { #markdown-style-links }
|
||||
|
||||
Это [Markdown-ссылка](https://example.com) на внешний сайт.
|
||||
|
||||
Это ссылка с атрибутами: [**FastAPI** генераторы проектов](project-generation.md){.internal-link target=_blank}
|
||||
|
||||
Это ссылка на основной сайт FastAPI: [FastAPI](https://fastapi.tiangolo.com/lang) — инструмент должен добавить код языка в URL.
|
||||
|
||||
Это ссылка на одну из страниц на сайте FastAPI: [How to](https://fastapi.tiangolo.com/lang/how-to/) — инструмент должен добавить код языка в URL.
|
||||
|
||||
Ссылка для тестирования неправильного атрибута: [**FastAPI** генераторы проектов](project-generation.md){.internal-link} - инструмент должен исправить атрибут.
|
||||
|
||||
Ссылка с заголовком: [Пример](https://example.com "Сайт для примера") - URL будет исправлен инструментом, заголовок сохранится.
|
||||
|
||||
### Markdown ссылки на статические ресурсы { #markdown-link-to-static-assets }
|
||||
|
||||
Это ссылки на статические ресурсы:
|
||||
|
||||
* [FastAPI Logo](https://fastapi.tiangolo.com/img/fastapi-logo.png)
|
||||
* [FastAPI CSS](https://fastapi.tiangolo.com/css/fastapi.css)
|
||||
* [FastAPI JS](https://fastapi.tiangolo.com/js/fastapi.js)
|
||||
|
||||
Инструмент НЕ должен добавлять код языка в их URL.
|
||||
|
||||
## Ссылки в стиле HTML { #html-style-links }
|
||||
|
||||
Это <a href="https://example.com" target="_blank" class="external-link">HTML-ссылка</a> на внешний сайт.
|
||||
|
||||
Это <a href="https://fastapi.tiangolo.com/lang">ссылка на основной сайт FastAPI</a> — инструмент должен добавить код языка в URL.
|
||||
|
||||
Это <a href="https://fastapi.tiangolo.com/lang/how-to/">ссылка на одну из страниц на сайте FastAPI</a> — инструмент должен добавить код языка в URL.
|
||||
|
||||
Ссылка для тестирования неправильного атрибута: <a href="project-generation.md" class="internal-link">**FastAPI** генераторы проектов</a> - инструмент должен исправить атрибут.
|
||||
|
||||
### HTML ссылки на статические ресурсы { #html-links-to-static-assets }
|
||||
|
||||
Это ссылки на статические ресурсы:
|
||||
|
||||
* <a href="https://fastapi.tiangolo.com/img/fastapi-logo.png">FastAPI Logo</a>
|
||||
* <a href="https://fastapi.tiangolo.com/css/fastapi.css">FastAPI CSS</a>
|
||||
* <a href="https://fastapi.tiangolo.com/js/fastapi.js">FastAPI JS</a>
|
||||
|
||||
Инструмент НЕ должен добавлять код языка в их URL.
|
||||
|
||||
# Заголовок (с HTML ссылкой на <a href="https://tiangolo.com">tiangolo.com</a>) { #header-with-html-link-to-tiangolo-com }
|
||||
|
||||
#Не заголовок
|
||||
|
||||
```Python
|
||||
# Также не заголовок
|
||||
```
|
||||
|
||||
Немного текста
|
||||
@@ -0,0 +1,30 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_complex_doc/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_fix(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = (data_path / "translated_doc_expected.md").read_text()
|
||||
assert fixed_content == expected_content
|
||||
|
||||
assert "Fixing multiline code blocks in" in result.output
|
||||
assert "Fixing markdown links in" in result.output
|
||||
@@ -0,0 +1,19 @@
|
||||
# Header 1 { #header-1 }
|
||||
|
||||
Some text
|
||||
|
||||
## Header 2 { #header-2 }
|
||||
|
||||
Some more text
|
||||
|
||||
### Header 3 { #header-3 }
|
||||
|
||||
Even more text
|
||||
|
||||
# Header 4 { #header-4 }
|
||||
|
||||
A bit more text
|
||||
|
||||
#Not a header
|
||||
|
||||
Final portion of text
|
||||
@@ -0,0 +1,19 @@
|
||||
# Header 1 { #header-1 }
|
||||
|
||||
Some text
|
||||
|
||||
# Header 2 { #header-2 }
|
||||
|
||||
Some more text
|
||||
|
||||
### Header 3 { #header-3 }
|
||||
|
||||
Even more text
|
||||
|
||||
# Header 4 { #header-4 }
|
||||
|
||||
A bit more text
|
||||
|
||||
#Not a header
|
||||
|
||||
Final portion of text
|
||||
@@ -0,0 +1,19 @@
|
||||
# Header 1 { #header-1 }
|
||||
|
||||
Some text
|
||||
|
||||
## Header 2 { #header-2 }
|
||||
|
||||
Some more text
|
||||
|
||||
### Header 3 { #header-3 }
|
||||
|
||||
Even more text
|
||||
|
||||
## Header 4 { #header-4 }
|
||||
|
||||
A bit more text
|
||||
|
||||
#Not a header
|
||||
|
||||
Final portion of text
|
||||
@@ -0,0 +1,19 @@
|
||||
# Header 1 { #header-1 }
|
||||
|
||||
Some text
|
||||
|
||||
## Header 2 { #header-2 }
|
||||
|
||||
Some more text
|
||||
|
||||
### Header 3 { #header-3 }
|
||||
|
||||
Even more text
|
||||
|
||||
# Header 4 { #header-4 }
|
||||
|
||||
A bit more text
|
||||
|
||||
# Extra header
|
||||
|
||||
Final portion of text
|
||||
@@ -0,0 +1,19 @@
|
||||
# Header 1 { #header-1 }
|
||||
|
||||
Some text
|
||||
|
||||
## Header 2 { #header-2 }
|
||||
|
||||
Some more text
|
||||
|
||||
### Header 3 { #header-3 }
|
||||
|
||||
Even more text
|
||||
|
||||
Header 4 is missing
|
||||
|
||||
A bit more text
|
||||
|
||||
#Not a header
|
||||
|
||||
Final portion of text
|
||||
@@ -0,0 +1,60 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_header_permalinks/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_level_mismatch_1.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_level_mismatch_1(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_level_mismatch_1.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Header levels do not match between document and original document"
|
||||
" (found #, expected ##) for header №2 in line 5"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_level_mismatch_2.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_level_mismatch_2(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(
|
||||
f"{data_path}/translated_doc_level_mismatch_2.md"
|
||||
).read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Header levels do not match between document and original document"
|
||||
" (found ##, expected #) for header №4 in line 13"
|
||||
) in result.output
|
||||
@@ -0,0 +1,56 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_header_permalinks/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_gt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of headers with permalinks does not match the number "
|
||||
"in the original document (5 vs 4)"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_lt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of headers with permalinks does not match the number "
|
||||
"in the original document (3 vs 4)"
|
||||
) in result.output
|
||||
@@ -0,0 +1,19 @@
|
||||
# Header 1 { #header-1 }
|
||||
|
||||
Some text with a link to <a href="https://fastapi.tiangolo.com">FastAPI</a>.
|
||||
|
||||
## Header 2 { #header-2 }
|
||||
|
||||
Two links here: <a href="https://fastapi.tiangolo.com/how-to/">How to</a> and <a href="project-generation.md" class="internal-link" target="_blank">Project Generators</a>.
|
||||
|
||||
### Header 3 { #header-3 }
|
||||
|
||||
Another link: <a href="project-generation.md" class="internal-link" target="_blank" title="Link title">**FastAPI** Project Generators</a> with title.
|
||||
|
||||
# Header 4 { #header-4 }
|
||||
|
||||
Link to anchor: <a href="#header-2">Header 2</a>
|
||||
|
||||
# Header with <a href="http://example.com">link</a> { #header-with-link }
|
||||
|
||||
Some text
|
||||
@@ -0,0 +1,21 @@
|
||||
# Заголовок 1 { #header-1 }
|
||||
|
||||
Немного текста со ссылкой на <a href="https://fastapi.tiangolo.com">FastAPI</a>.
|
||||
|
||||
## Заголовок 2 { #header-2 }
|
||||
|
||||
Две ссылки здесь: <a href="https://fastapi.tiangolo.com/how-to/">How to</a> и <a href="project-generation.md" class="internal-link" target="_blank">Project Generators</a>.
|
||||
|
||||
### Заголовок 3 { #header-3 }
|
||||
|
||||
Ещё ссылка: <a href="project-generation.md" class="internal-link" target="_blank" title="Тайтл">**FastAPI** Генераторы Проектов</a> с тайтлом.
|
||||
|
||||
И ещё одна <a href="https://github.com">экстра ссылка</a>.
|
||||
|
||||
# Заголовок 4 { #header-4 }
|
||||
|
||||
Ссылка на якорь: <a href="#header-2">Заголовок 2</a>
|
||||
|
||||
# Заголовок со <a href="http://example.com">ссылкой</a> { #header-with-link }
|
||||
|
||||
Немного текста
|
||||
@@ -0,0 +1,19 @@
|
||||
# Заголовок 1 { #header-1 }
|
||||
|
||||
Немного текста со ссылкой на <a href="https://fastapi.tiangolo.com">FastAPI</a>.
|
||||
|
||||
## Заголовок 2 { #header-2 }
|
||||
|
||||
Две ссылки здесь: <a href="https://fastapi.tiangolo.com/how-to/">How to</a> и <a href="project-generation.md" class="internal-link" target="_blank">Project Generators</a>.
|
||||
|
||||
### Заголовок 3 { #header-3 }
|
||||
|
||||
Ещё ссылка: <a href="project-generation.md" class="internal-link" target="_blank" title="Тайтл">**FastAPI** Генераторы Проектов</a> с тайтлом.
|
||||
|
||||
# Заголовок 4 { #header-4 }
|
||||
|
||||
Ссылка на якорь: <a href="#header-2">Заголовок 2</a>
|
||||
|
||||
# Заголовок с потерянной ссылкой { #header-with-link }
|
||||
|
||||
Немного текста
|
||||
@@ -0,0 +1,54 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path("scripts/tests/test_translation_fixer/test_html_links/data").absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_gt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of HTML links does not match the number "
|
||||
"in the original document (7 vs 6)"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_lt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
# assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of HTML links does not match the number "
|
||||
"in the original document (5 vs 6)"
|
||||
) in result.output
|
||||
@@ -0,0 +1,19 @@
|
||||
# Header 1 { #header-1 }
|
||||
|
||||
Some text with a link to [FastAPI](https://fastapi.tiangolo.com).
|
||||
|
||||
## Header 2 { #header-2 }
|
||||
|
||||
Two links here: [How to](https://fastapi.tiangolo.com/how-to/) and [Project Generators](project-generation.md){.internal-link target=_blank}.
|
||||
|
||||
### Header 3 { #header-3 }
|
||||
|
||||
Another link: [**FastAPI** Project Generators](project-generation.md "Link title"){.internal-link target=_blank} with title.
|
||||
|
||||
# Header 4 { #header-4 }
|
||||
|
||||
Link to anchor: [Header 2](#header-2)
|
||||
|
||||
# Header with [link](http://example.com) { #header-with-link }
|
||||
|
||||
Some text
|
||||
@@ -0,0 +1,19 @@
|
||||
# Заголовок 1 { #header-1 }
|
||||
|
||||
Немного текста со ссылкой на [FastAPI](https://fastapi.tiangolo.com).
|
||||
|
||||
## Заголовок 2 { #header-2 }
|
||||
|
||||
Две ссылки здесь: [How to](https://fastapi.tiangolo.com/how-to/) и [Project Generators](project-generation.md){.internal-link target=_blank}.
|
||||
|
||||
### Заголовок 3 { #header-3 }
|
||||
|
||||
Ещё ссылка: [**FastAPI** Генераторы Проектов](project-generation.md "Тайтл"){.internal-link target=_blank} с тайтлом.
|
||||
|
||||
# Заголовок 4 { #header-4 }
|
||||
|
||||
Ссылка на якорь: [Заголовок 2](#header-2)
|
||||
|
||||
# Заголовок со [ссылкой](http://example.com) { #header-with-link }
|
||||
|
||||
Немного текста
|
||||
@@ -0,0 +1,21 @@
|
||||
# Заголовок 1 { #header-1 }
|
||||
|
||||
Немного текста со ссылкой на [FastAPI](https://fastapi.tiangolo.com).
|
||||
|
||||
## Заголовок 2 { #header-2 }
|
||||
|
||||
Две ссылки здесь: [How to](https://fastapi.tiangolo.com/how-to/) и [Project Generators](project-generation.md){.internal-link target=_blank}.
|
||||
|
||||
### Заголовок 3 { #header-3 }
|
||||
|
||||
Ещё ссылка: [**FastAPI** Генераторы Проектов](project-generation.md "Тайтл"){.internal-link target=_blank} с тайтлом.
|
||||
|
||||
И ещё одна [экстра ссылка](https://github.com).
|
||||
|
||||
# Заголовок 4 { #header-4 }
|
||||
|
||||
Ссылка на якорь: [Заголовок 2](#header-2)
|
||||
|
||||
# Заголовок со [ссылкой](http://example.com) { #header-with-link }
|
||||
|
||||
Немного текста
|
||||
@@ -0,0 +1,19 @@
|
||||
# Заголовок 1 { #header-1 }
|
||||
|
||||
Немного текста со ссылкой на [FastAPI](https://fastapi.tiangolo.com).
|
||||
|
||||
## Заголовок 2 { #header-2 }
|
||||
|
||||
Две ссылки здесь: [How to](https://fastapi.tiangolo.com/how-to/) и [Project Generators](project-generation.md){.internal-link target=_blank}.
|
||||
|
||||
### Заголовок 3 { #header-3 }
|
||||
|
||||
Ещё ссылка: [**FastAPI** Генераторы Проектов](project-generation.md "Тайтл"){.internal-link target=_blank} с тайтлом.
|
||||
|
||||
# Заголовок 4 { #header-4 }
|
||||
|
||||
Ссылка на якорь: [Заголовок 2](#header-2)
|
||||
|
||||
# Заголовок с потерянной ссылкой { #header-with-link }
|
||||
|
||||
Немного текста
|
||||
@@ -0,0 +1,56 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from scripts.translation_fixer import cli
|
||||
|
||||
data_path = Path(
|
||||
"scripts/tests/test_translation_fixer/test_markdown_links/data"
|
||||
).absolute()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_gt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of markdown links does not match the number "
|
||||
"in the original document (7 vs 6)"
|
||||
) in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"copy_test_files",
|
||||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_lt.md")],
|
||||
indirect=True,
|
||||
)
|
||||
def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
["fix-pages", "docs/lang/docs/doc.md"],
|
||||
)
|
||||
# assert result.exit_code == 1, result.output
|
||||
|
||||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
|
||||
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
|
||||
|
||||
assert fixed_content == expected_content # Translated doc remains unchanged
|
||||
assert "Error processing docs/lang/docs/doc.md" in result.output
|
||||
assert (
|
||||
"Number of markdown links does not match the number "
|
||||
"in the original document (5 vs 6)"
|
||||
) in result.output
|
||||
@@ -10,6 +10,7 @@ from typing import Annotated
|
||||
import git
|
||||
import typer
|
||||
import yaml
|
||||
from doc_parsing_utils import check_translation
|
||||
from github import Github
|
||||
from pydantic_ai import Agent
|
||||
from rich import print
|
||||
@@ -25,650 +26,8 @@ non_translated_sections = (
|
||||
"contributing.md",
|
||||
)
|
||||
|
||||
|
||||
general_prompt = """
|
||||
### About literal text in this prompt
|
||||
|
||||
1) In the following instructions (after I say: `The above rules are in effect now`) the two characters `«` and `»` will be used to surround LITERAL TEXT, which is text or characters you shall interpret literally. The `«` and the `»` are not part of the literal text, they are the meta characters denoting it.
|
||||
|
||||
2) Furthermore, text surrounded by `«««` and `»»»` is a BLOCK OF LITERAL TEXT which spans multiple lines. To get its content, dedent all lines of the block until the `«««` and `»»»` are at column zero, then remove the newline (`\n`) after the `«««` and the newline before the `»»»`. The `«««` and the `»»»` are not part of the literal text block, they are the meta characters denoting it.
|
||||
|
||||
3) If you see backticks or any other quotes inside literal text – inside `«` and `»` – or inside blocks of literal text – inside `«««` and `»»»` – then interpret them as literal characters, do NOT interpret them as meta characters.
|
||||
|
||||
The above rules are in effect now.
|
||||
|
||||
|
||||
### Definitions of terms used in this prompt
|
||||
|
||||
"backtick"
|
||||
|
||||
The character «`»
|
||||
Unicode U+0060 (GRAVE ACCENT)
|
||||
|
||||
"single backtick"
|
||||
|
||||
A single backtick – «`»
|
||||
|
||||
"triple backticks"
|
||||
|
||||
Three backticks in a row – «```»
|
||||
|
||||
"neutral double quote"
|
||||
|
||||
The character «"»
|
||||
Unicode U+0022 (QUOTATION MARK)
|
||||
|
||||
"neutral single quote"
|
||||
|
||||
The character «'»
|
||||
Unicode U+0027 (APOSTROPHE)
|
||||
|
||||
"English double typographic quotes"
|
||||
|
||||
The characters «“» and «”»
|
||||
Unicode U+201C (LEFT DOUBLE QUOTATION MARK) and Unicode U+201D (RIGHT DOUBLE QUOTATION MARK)
|
||||
|
||||
"English single typographic quotes"
|
||||
|
||||
The characters «‘» and «’»
|
||||
Unicode U+2018 (LEFT SINGLE QUOTATION MARK) and Unicode U+2019 (RIGHT SINGLE QUOTATION MARK)
|
||||
|
||||
"code snippet"
|
||||
|
||||
Also called "inline code". Text in a Markdown document which is surrounded by single backticks. A paragraph in a Markdown document can have a more than one code snippet.
|
||||
|
||||
Example:
|
||||
|
||||
«««
|
||||
`i am a code snippet`
|
||||
»»»
|
||||
|
||||
Example:
|
||||
|
||||
«««
|
||||
`first code snippet` `second code snippet` `third code snippet`
|
||||
»»»
|
||||
|
||||
"code block"
|
||||
|
||||
Text in a Markdown document which is surrounded by triple backticks. Spreads multiple lines.
|
||||
|
||||
Example:
|
||||
|
||||
«««
|
||||
```
|
||||
Hello
|
||||
World
|
||||
```
|
||||
»»»
|
||||
|
||||
Example:
|
||||
|
||||
«««
|
||||
```python
|
||||
print("hello World")
|
||||
```
|
||||
»»»
|
||||
|
||||
"HTML element"
|
||||
|
||||
a HTML opening tag – e.g. «<div>» – and a HTML closing tag – e.g. «</div>» – surrounding text or other HTML elements.
|
||||
|
||||
|
||||
### Your task
|
||||
|
||||
Translate an English text – the original content – to a target language.
|
||||
|
||||
The original content is written in Markdown, write the translation in Markdown as well.
|
||||
|
||||
The original content will be surrounded by triple percentage signs («%%%»). Do not include the triple percentage signs in the translation.
|
||||
|
||||
|
||||
### Technical terms in English
|
||||
|
||||
For technical terms in English that don't have a common translation term, use the original term in English.
|
||||
|
||||
|
||||
### Content of code snippets
|
||||
|
||||
Do not translate the content of code snippets, keep the original in English. For example, «`list`», «`dict`», keep them as is.
|
||||
|
||||
|
||||
### Content of code blocks
|
||||
|
||||
Do not translate the content of code blocks, except for comments in the language which the code block uses.
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English) – The code block is a bash code example with one comment:
|
||||
|
||||
«««
|
||||
```bash
|
||||
# Print greeting
|
||||
echo "Hello, World!"
|
||||
```
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
```bash
|
||||
# Gruß ausgeben
|
||||
echo "Hello, World!"
|
||||
```
|
||||
»»»
|
||||
|
||||
Source (English) – The code block is a console example containing HTML tags. No comments, so nothing to change here:
|
||||
|
||||
«««
|
||||
```console
|
||||
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
|
||||
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server
|
||||
Searching for package file structure
|
||||
```
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
```console
|
||||
$ <font color="#4E9A06">fastapi</font> run <u style="text-decoration-style:solid">main.py</u>
|
||||
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting server
|
||||
Searching for package file structure
|
||||
```
|
||||
»»»
|
||||
|
||||
Source (English) – The code block is a console example containing 5 comments:
|
||||
|
||||
«««
|
||||
```console
|
||||
// Go to the home directory
|
||||
$ cd
|
||||
// Create a directory for all your code projects
|
||||
$ mkdir code
|
||||
// Enter into that code directory
|
||||
$ cd code
|
||||
// Create a directory for this project
|
||||
$ mkdir awesome-project
|
||||
// Enter into that project directory
|
||||
$ cd awesome-project
|
||||
```
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
```console
|
||||
// Gehe zum Home-Verzeichnis
|
||||
$ cd
|
||||
// Erstelle ein Verzeichnis für alle Ihre Code-Projekte
|
||||
$ mkdir code
|
||||
// Gehe in dieses Code-Verzeichnis
|
||||
$ cd code
|
||||
// Erstelle ein Verzeichnis für dieses Projekt
|
||||
$ mkdir awesome-project
|
||||
// Gehe in dieses Projektverzeichnis
|
||||
$ cd awesome-project
|
||||
```
|
||||
»»»
|
||||
|
||||
If there is an existing translation and its Mermaid diagram is in sync with the Mermaid diagram in the English source, except a few translated words, then use the Mermaid diagram of the existing translation. The human editor of the translation translated these words in the Mermaid diagram. Keep these translations, do not revert them back to the English source.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[global env]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone project]
|
||||
stone(philosophers-stone) -->|requires| harry-1
|
||||
end
|
||||
```
|
||||
»»»
|
||||
|
||||
Existing translation (German) – has three translations:
|
||||
|
||||
«««
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[globale Umgebung]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone-Projekt]
|
||||
stone(philosophers-stone) -->|benötigt| harry-1
|
||||
end
|
||||
```
|
||||
»»»
|
||||
|
||||
Result (German) – you change nothing:
|
||||
|
||||
«««
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[globale Umgebung]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone-Projekt]
|
||||
stone(philosophers-stone) -->|benötigt| harry-1
|
||||
end
|
||||
```
|
||||
»»»
|
||||
|
||||
|
||||
### Special blocks
|
||||
|
||||
There are special blocks of notes, tips and others that look like:
|
||||
|
||||
«««
|
||||
/// note
|
||||
»»»
|
||||
|
||||
To translate it, keep the same line and add the translation after a vertical bar.
|
||||
|
||||
For example, if you were translating to Spanish, you would write:
|
||||
|
||||
«««
|
||||
/// note | Nota
|
||||
»»»
|
||||
|
||||
Some examples in Spanish:
|
||||
|
||||
Source:
|
||||
|
||||
«««
|
||||
/// tip
|
||||
»»»
|
||||
|
||||
Result:
|
||||
|
||||
«««
|
||||
/// tip | Consejo
|
||||
»»»
|
||||
|
||||
Source:
|
||||
|
||||
«««
|
||||
/// details | Preview
|
||||
»»»
|
||||
|
||||
Result:
|
||||
|
||||
«««
|
||||
/// details | Vista previa
|
||||
»»»
|
||||
|
||||
|
||||
### Tab blocks
|
||||
|
||||
There are special blocks surrounded by four slashes («////»). They mark text, which will be rendered as part of a tab in the final document. The scheme is:
|
||||
|
||||
//// tab | {tab title}
|
||||
{tab content, may span many lines}
|
||||
////
|
||||
|
||||
Keep everything before the vertical bar («|») as is, including the vertical bar. Translate the tab title. Translate the tab content, applying the rules you know. Keep the four block closing slashes as is.
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
//// tab | Python 3.8+ non-Annotated
|
||||
Hello
|
||||
////
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
//// tab | Python 3.8+ nicht annotiert
|
||||
Hallo
|
||||
////
|
||||
»»»
|
||||
|
||||
Source (English) – Here there is nothing to translate in the tab title:
|
||||
|
||||
«««
|
||||
//// tab | Linux, macOS, Windows Bash
|
||||
Hello again
|
||||
////
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
//// tab | Linux, macOS, Windows Bash
|
||||
Hallo wieder
|
||||
////
|
||||
»»»
|
||||
|
||||
|
||||
### Headings
|
||||
|
||||
Every Markdown heading in the English text (all levels) ends with a part inside curly brackets. This part denotes the hash of this heading, which is used in links to this heading. In translations, translate the heading, but do not translate this hash part, so that links do not break.
|
||||
|
||||
Examples of how to translate a heading:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
## Alternative API docs { #alternative-api-docs }
|
||||
»»»
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
«««
|
||||
## Documentación de la API alternativa { #alternative-api-docs }
|
||||
»»»
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
### Example { #example }
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
### Beispiel { #example }
|
||||
»»»
|
||||
|
||||
|
||||
### Links
|
||||
|
||||
Use the following rules for links (apply both to Markdown-style links ([text](url)) and to HTML-style <a> tags):
|
||||
|
||||
1) For relative URLs, only translate link text. Do not translate the URL or its parts
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
[One of the fastest Python frameworks available](#performance)
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
[Eines der schnellsten verfügbaren Python-Frameworks](#performance)
|
||||
»»»
|
||||
|
||||
2) For absolute URLs which DO NOT start EXACTLY with «https://fastapi.tiangolo.com», only translate link text and leave the URL unchanged.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel docs</a>
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
<a href="https://sqlmodel.tiangolo.com/" class="external-link" target="_blank">SQLModel-Dokumentation</a>
|
||||
»»»
|
||||
|
||||
3) For absolute URLs which DO start EXACTLY with «https://fastapi.tiangolo.com», only translate link text and change the URL by adding language code («https://fastapi.tiangolo.com/{language_code}[rest part of the url]»).
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<a href="https://fastapi.tiangolo.com/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentation</a>
|
||||
»»»
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
«««
|
||||
<a href="https://fastapi.tiangolo.com/es/tutorial/path-params/#documentation" class="external-link" target="_blank">Documentación</a>
|
||||
»»»
|
||||
|
||||
3.1) Do not add language codes for URLs that point to static assets (e.g., images, CSS, JavaScript).
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Something</a>
|
||||
»»»
|
||||
|
||||
Result (Spanish):
|
||||
|
||||
«««
|
||||
<a href="https://fastapi.tiangolo.com/img/something.jpg" class="external-link" target="_blank">Algo</a>
|
||||
»»»
|
||||
|
||||
4) For internal links, only translate link text.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
[Create Pull Requests](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
[Pull Requests erzeugen](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}
|
||||
»»»
|
||||
|
||||
5) Do not translate anchor fragments in links (the part after «#»), as they must remain the same to work correctly.
|
||||
|
||||
5.1) If an existing translation has a link with an anchor fragment different to the anchor fragment in the English source, then this is an error. Fix this by using the anchor fragment of the English source.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
[Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}
|
||||
»»»
|
||||
|
||||
Existing wrong translation (German) – notice the wrongly translated anchor fragment:
|
||||
|
||||
«««
|
||||
[Body – Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#einzelne-werte-im-body){.internal-link target=_blank}.
|
||||
»»»
|
||||
|
||||
Result (German) – you fix the anchor fragment:
|
||||
|
||||
«««
|
||||
[Body – Mehrere Parameter: Einfache Werte im Body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}.
|
||||
»»»
|
||||
|
||||
5.2) Do not add anchor fragments at will, even if this makes sense. If the English source has no anchor, don't add one.
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
Create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}
|
||||
»»»
|
||||
|
||||
Wrong translation (German) – Anchor added to the URL.
|
||||
|
||||
«««
|
||||
Erstelle eine [virtuelle Umgebung](../virtual-environments.md#create-a-virtual-environment){.internal-link target=_blank}
|
||||
»»»
|
||||
|
||||
Good translation (German) – URL stays like in the English source.
|
||||
|
||||
«««
|
||||
Erstelle eine [Virtuelle Umgebung](../virtual-environments.md){.internal-link target=_blank}
|
||||
»»»
|
||||
|
||||
|
||||
### HTML abbr elements
|
||||
|
||||
Translate HTML abbr elements («<abbr title="description">text</abbr>») as follows:
|
||||
|
||||
1) If the text surrounded by the abbr element is an abbreviation (the text may be surrounded by further HTML or Markdown markup or quotes, for example «<code>text</code>» or «`text`» or «"text"», ignore that further markup when deciding if the text is an abbreviation), and if the description (the text inside the title attribute) contains the full phrase for this abbreviation, then append a dash («–») to the full phrase, followed by the translation of the full phrase.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
<abbr title="{full phrase}">{abbreviation}</abbr>
|
||||
|
||||
Result:
|
||||
|
||||
<abbr title="{full phrase} – {translation of full phrase}">{abbreviation}</abbr>
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<abbr title="Internet of Things">IoT</abbr>
|
||||
<abbr title="Central Processing Unit">CPU</abbr>
|
||||
<abbr title="too long; didn't read"><strong>TL;DR:</strong></abbr>
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
<abbr title="Internet of Things – Internet der Dinge">IoT</abbr>
|
||||
<abbr title="Central Processing Unit – Zentrale Verarbeitungseinheit">CPU</abbr>
|
||||
<abbr title="too long; didn't read – zu lang; hab's nicht gelesen"><strong>TL;DR:</strong></abbr>
|
||||
»»»
|
||||
|
||||
1.1) If the language to which you translate mostly uses the letters of the ASCII char set (for example Spanish, French, German, but not Russian, Chinese) and if the translation of the full phrase is identical to, or starts with the same letters as the original full phrase, then only give the translation of the full phrase.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
<abbr title="{full phrase}">{abbreviation}</abbr>
|
||||
|
||||
Result:
|
||||
|
||||
<abbr title="{translation of full phrase}">{abbreviation}</abbr>
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<abbr title="JSON Web Tokens">JWT</abbr>
|
||||
<abbr title="Enumeration">Enum</abbr>
|
||||
<abbr title="Asynchronous Server Gateway Interface">ASGI</abbr>
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
<abbr title="JSON Web Tokens">JWT</abbr>
|
||||
<abbr title="Enumeration">Enum</abbr>
|
||||
<abbr title="Asynchrones Server-Gateway-Interface">ASGI</abbr>
|
||||
»»»
|
||||
|
||||
2) If the description is not a full phrase for an abbreviation which the abbr element surrounds, but some other information, then just translate the description.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
<abbr title="{description}">{text}</abbr>
|
||||
|
||||
Result:
|
||||
|
||||
<abbr title="{translation of description}">{translation of text}</abbr>
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<abbr title="also known as: endpoints, routes">path</abbr>
|
||||
<abbr title="a program that checks for code errors">linter</abbr>
|
||||
<abbr title="converting the string that comes from an HTTP request into Python data">parsing</abbr>
|
||||
<abbr title="before 2023-03">0.95.0</abbr>
|
||||
<abbr title="2023-08-26">at the time of writing this</abbr>
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
<abbr title="auch bekannt als: Endpunkte, Routen">Pfad</abbr>
|
||||
<abbr title="Programm das auf Fehler im Code prüft">Linter</abbr>
|
||||
<abbr title="Konvertieren des Strings eines HTTP-Requests in Python-Daten">Parsen</abbr>
|
||||
<abbr title="vor 2023-03">0.95.0</abbr>
|
||||
<abbr title="2023-08-26">zum Zeitpunkt als das hier geschrieben wurde</abbr>
|
||||
»»»
|
||||
|
||||
|
||||
3) If the text surrounded by the abbr element is an abbreviation and the description contains both the full phrase for that abbreviation, and other information, separated by a colon («:»), then append a dash («–») and the translation of the full phrase to the original full phrase and translate the other information.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
<abbr title="{full phrase}: {other information}">{abbreviation}</abbr>
|
||||
|
||||
Result:
|
||||
|
||||
<abbr title="{full phrase} – {translation of full phrase}: {translation of other information}">{abbreviation}</abbr>
|
||||
|
||||
Examples:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<abbr title="Input/Output: disk reading or writing, network communication.">I/O</abbr>
|
||||
<abbr title="Content Delivery Network: service, that provides static files.">CDN</abbr>
|
||||
<abbr title="Integrated Development Environment: similar to a code editor">IDE</abbr>
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
<abbr title="Input/Output – Eingabe/Ausgabe: Lesen oder Schreiben auf der Festplatte, Netzwerkkommunikation.">I/O</abbr>
|
||||
<abbr title="Content Delivery Network – Inhalte auslieferndes Netzwerk: Dienst, der statische Dateien bereitstellt.">CDN</abbr>
|
||||
<abbr title="Integrated Development Environment – Integrierte Entwicklungsumgebung: Ähnlich einem Code-Editor">IDE</abbr>
|
||||
»»»
|
||||
|
||||
3.1) Like in rule 2.1, you can leave the original full phrase away, if the translated full phrase is identical or starts with the same letters as the original full phrase.
|
||||
|
||||
Conversion scheme:
|
||||
|
||||
Source (English):
|
||||
|
||||
<abbr title="{full phrase}: {information}">{abbreviation}</abbr>
|
||||
|
||||
Result:
|
||||
|
||||
<abbr title="{translation of full phrase}: {translation of information}">{abbreviation}</abbr>
|
||||
|
||||
Example:
|
||||
|
||||
Source (English):
|
||||
|
||||
«««
|
||||
<abbr title="Object Relational Mapper: a fancy term for a library where some classes represent SQL tables and instances represent rows in those tables">ORM</abbr>
|
||||
»»»
|
||||
|
||||
Result (German):
|
||||
|
||||
«««
|
||||
<abbr title="Objektrelationaler Mapper: Ein Fachbegriff für eine Bibliothek, in der einige Klassen SQL-Tabellen und Instanzen Zeilen in diesen Tabellen darstellen">ORM</abbr>
|
||||
»»»
|
||||
|
||||
4) If there is an existing translation, and it has ADDITIONAL abbr elements in a sentence, and these additional abbr elements do not exist in the related sentence in the English text, then KEEP those additional abbr elements in the translation. Do not remove them. Except when you remove the whole sentence from the translation, because the whole sentence was removed from the English text, then also remove the abbr element. The reasoning for this rule is, that such additional abbr elements are manually added by the human editor of the translation, in order to translate or explain an English word to the human readers of the translation. These additional abbr elements would not make sense in the English text, but they do make sense in the translation. So keep them in the translation, even though they are not part of the English text. This rule only applies to abbr elements.
|
||||
|
||||
5) Apply above rules also when there is an existing translation! Make sure that all title attributes in abbr elements get properly translated or updated, using the schemes given above. However, leave the ADDITIONAL abbr's from rule 4 alone. Do not change their formatting or content.
|
||||
|
||||
"""
|
||||
general_prompt_path = Path(__file__).absolute().parent / "llm-general-prompt.md"
|
||||
general_prompt = general_prompt_path.read_text(encoding="utf-8")
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
@@ -761,9 +120,27 @@ def translate_page(
|
||||
]
|
||||
)
|
||||
prompt = "\n\n".join(prompt_segments)
|
||||
print(f"Running agent for {out_path}")
|
||||
result = agent.run_sync(prompt)
|
||||
out_content = f"{result.output.strip()}\n"
|
||||
|
||||
for attempt_no in range(1, 4):
|
||||
print(f"Running agent for {out_path} (attempt {attempt_no}/3)")
|
||||
result = agent.run_sync(prompt)
|
||||
out_content = f"{result.output.strip()}\n"
|
||||
try:
|
||||
check_translation(
|
||||
doc_lines=out_content.splitlines(),
|
||||
en_doc_lines=original_content.splitlines(),
|
||||
lang_code=language,
|
||||
auto_fix=False,
|
||||
path=str(out_path),
|
||||
)
|
||||
break # Exit loop if no errors
|
||||
except ValueError as e:
|
||||
print(f"Translation check failed on attempt {attempt_no}/3: {e}")
|
||||
continue # Retry if not reached max attempts
|
||||
else: # Max retry attempts reached
|
||||
print(f"Translation failed for {out_path} after 3 attempts")
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
print(f"Saving translation to {out_path}")
|
||||
out_path.write_text(out_content, encoding="utf-8", newline="\n")
|
||||
|
||||
@@ -1036,9 +413,13 @@ def make_pr(
|
||||
print("Creating PR")
|
||||
g = Github(github_token)
|
||||
gh_repo = g.get_repo(github_repository)
|
||||
pr = gh_repo.create_pull(
|
||||
title=message, body=message, base="master", head=branch_name
|
||||
body = (
|
||||
message
|
||||
+ "\n\nThis PR was created automatically using LLMs."
|
||||
+ f"\n\nIt uses the prompt file https://github.com/fastapi/fastapi/blob/master/docs/{language}/llm-prompt.md."
|
||||
+ "\n\nIn most cases, it's better to make PRs updating that file so that the LLM can do a better job generating the translations than suggesting changes in this PR."
|
||||
)
|
||||
pr = gh_repo.create_pull(title=message, body=body, base="master", head=branch_name)
|
||||
print(f"Created PR: {pr.number}")
|
||||
print("Finished")
|
||||
|
||||
|
||||
132
scripts/translation_fixer.py
Normal file
132
scripts/translation_fixer.py
Normal file
@@ -0,0 +1,132 @@
|
||||
import os
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
from typing import Annotated
|
||||
|
||||
import typer
|
||||
|
||||
from scripts.doc_parsing_utils import check_translation
|
||||
|
||||
non_translated_sections = (
|
||||
f"reference{os.sep}",
|
||||
"release-notes.md",
|
||||
"fastapi-people.md",
|
||||
"external-links.md",
|
||||
"newsletter.md",
|
||||
"management-tasks.md",
|
||||
"management.md",
|
||||
"contributing.md",
|
||||
)
|
||||
|
||||
|
||||
cli = typer.Typer()
|
||||
|
||||
|
||||
@cli.callback()
|
||||
def callback():
|
||||
pass
|
||||
|
||||
|
||||
def iter_all_lang_paths(lang_path_root: Path) -> Iterable[Path]:
|
||||
"""
|
||||
Iterate on the markdown files to translate in order of priority.
|
||||
"""
|
||||
|
||||
first_dirs = [
|
||||
lang_path_root / "learn",
|
||||
lang_path_root / "tutorial",
|
||||
lang_path_root / "advanced",
|
||||
lang_path_root / "about",
|
||||
lang_path_root / "how-to",
|
||||
]
|
||||
first_parent = lang_path_root
|
||||
yield from first_parent.glob("*.md")
|
||||
for dir_path in first_dirs:
|
||||
yield from dir_path.rglob("*.md")
|
||||
first_dirs_str = tuple(str(d) for d in first_dirs)
|
||||
for path in lang_path_root.rglob("*.md"):
|
||||
if str(path).startswith(first_dirs_str):
|
||||
continue
|
||||
if path.parent == first_parent:
|
||||
continue
|
||||
yield path
|
||||
|
||||
|
||||
def get_all_paths(lang: str):
|
||||
res: list[str] = []
|
||||
lang_docs_root = Path("docs") / lang / "docs"
|
||||
for path in iter_all_lang_paths(lang_docs_root):
|
||||
relpath = path.relative_to(lang_docs_root)
|
||||
if not str(relpath).startswith(non_translated_sections):
|
||||
res.append(str(relpath))
|
||||
return res
|
||||
|
||||
|
||||
def process_one_page(path: Path) -> bool:
|
||||
"""
|
||||
Fix one translated document by comparing it to the English version.
|
||||
|
||||
Returns True if processed successfully, False otherwise.
|
||||
"""
|
||||
|
||||
try:
|
||||
lang_code = path.parts[1]
|
||||
if lang_code == "en":
|
||||
print(f"Skipping English document: {path}")
|
||||
return True
|
||||
|
||||
en_doc_path = Path("docs") / "en" / Path(*path.parts[2:])
|
||||
|
||||
doc_lines = path.read_text(encoding="utf-8").splitlines()
|
||||
en_doc_lines = en_doc_path.read_text(encoding="utf-8").splitlines()
|
||||
|
||||
doc_lines = check_translation(
|
||||
doc_lines=doc_lines,
|
||||
en_doc_lines=en_doc_lines,
|
||||
lang_code=lang_code,
|
||||
auto_fix=True,
|
||||
path=str(path),
|
||||
)
|
||||
|
||||
# Write back the fixed document
|
||||
doc_lines.append("") # Ensure file ends with a newline
|
||||
path.write_text("\n".join(doc_lines), encoding="utf-8")
|
||||
|
||||
except ValueError as e:
|
||||
print(f"Error processing {path}: {e}")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@cli.command()
|
||||
def fix_all(ctx: typer.Context, language: str):
|
||||
docs = get_all_paths(language)
|
||||
|
||||
all_good = True
|
||||
for page in docs:
|
||||
doc_path = Path("docs") / language / "docs" / page
|
||||
res = process_one_page(doc_path)
|
||||
all_good = all_good and res
|
||||
|
||||
if not all_good:
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
|
||||
@cli.command()
|
||||
def fix_pages(
|
||||
doc_paths: Annotated[
|
||||
list[Path],
|
||||
typer.Argument(help="List of paths to documents."),
|
||||
],
|
||||
):
|
||||
all_good = True
|
||||
for path in doc_paths:
|
||||
res = process_one_page(path)
|
||||
all_good = all_good and res
|
||||
|
||||
if not all_good:
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
@@ -1,13 +1,12 @@
|
||||
import json
|
||||
import sys
|
||||
import warnings
|
||||
from collections.abc import Iterator
|
||||
from typing import Annotated, Any
|
||||
|
||||
import pytest
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.exceptions import FastAPIDeprecationWarning
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import BaseModel
|
||||
|
||||
if "--codspeed" not in sys.argv:
|
||||
pytest.skip(
|
||||
@@ -47,148 +46,143 @@ def dep_b(a: Annotated[int, Depends(dep_a)]):
|
||||
return a + 2
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
scope="module",
|
||||
params=[
|
||||
"pydantic-v2",
|
||||
"pydantic-v1",
|
||||
],
|
||||
)
|
||||
def basemodel_class(request: pytest.FixtureRequest) -> type[Any]:
|
||||
if request.param == "pydantic-v2":
|
||||
from pydantic import BaseModel
|
||||
class ItemIn(BaseModel):
|
||||
name: str
|
||||
value: int
|
||||
|
||||
return BaseModel
|
||||
else:
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
return BaseModel
|
||||
class ItemOut(BaseModel):
|
||||
name: str
|
||||
value: int
|
||||
dep: int
|
||||
|
||||
|
||||
class LargeIn(BaseModel):
|
||||
items: list[dict[str, Any]]
|
||||
metadata: dict[str, Any]
|
||||
|
||||
|
||||
class LargeOut(BaseModel):
|
||||
items: list[dict[str, Any]]
|
||||
metadata: dict[str, Any]
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.post("/sync/validated", response_model=ItemOut)
|
||||
def sync_validated(item: ItemIn, dep: Annotated[int, Depends(dep_b)]):
|
||||
return ItemOut(name=item.name, value=item.value, dep=dep)
|
||||
|
||||
|
||||
@app.get("/sync/dict-no-response-model")
|
||||
def sync_dict_no_response_model():
|
||||
return {"name": "foo", "value": 123}
|
||||
|
||||
|
||||
@app.get("/sync/dict-with-response-model", response_model=ItemOut)
|
||||
def sync_dict_with_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return {"name": "foo", "value": 123, "dep": dep}
|
||||
|
||||
|
||||
@app.get("/sync/model-no-response-model")
|
||||
def sync_model_no_response_model(dep: Annotated[int, Depends(dep_b)]):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
|
||||
@app.get("/sync/model-with-response-model", response_model=ItemOut)
|
||||
def sync_model_with_response_model(dep: Annotated[int, Depends(dep_b)]):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
|
||||
@app.post("/async/validated", response_model=ItemOut)
|
||||
async def async_validated(
|
||||
item: ItemIn,
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return ItemOut(name=item.name, value=item.value, dep=dep)
|
||||
|
||||
|
||||
@app.post("/sync/large-receive")
|
||||
def sync_large_receive(payload: LargeIn):
|
||||
return {"received": len(payload.items)}
|
||||
|
||||
|
||||
@app.post("/async/large-receive")
|
||||
async def async_large_receive(payload: LargeIn):
|
||||
return {"received": len(payload.items)}
|
||||
|
||||
|
||||
@app.get("/sync/large-dict-no-response-model")
|
||||
def sync_large_dict_no_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
|
||||
@app.get("/sync/large-dict-with-response-model", response_model=LargeOut)
|
||||
def sync_large_dict_with_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
|
||||
@app.get("/sync/large-model-no-response-model")
|
||||
def sync_large_model_no_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
|
||||
@app.get("/sync/large-model-with-response-model", response_model=LargeOut)
|
||||
def sync_large_model_with_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
|
||||
@app.get("/async/large-dict-no-response-model")
|
||||
async def async_large_dict_no_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
|
||||
@app.get("/async/large-dict-with-response-model", response_model=LargeOut)
|
||||
async def async_large_dict_with_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
|
||||
@app.get("/async/large-model-no-response-model")
|
||||
async def async_large_model_no_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
|
||||
@app.get("/async/large-model-with-response-model", response_model=LargeOut)
|
||||
async def async_large_model_with_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
|
||||
@app.get("/async/dict-no-response-model")
|
||||
async def async_dict_no_response_model():
|
||||
return {"name": "foo", "value": 123}
|
||||
|
||||
|
||||
@app.get("/async/dict-with-response-model", response_model=ItemOut)
|
||||
async def async_dict_with_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return {"name": "foo", "value": 123, "dep": dep}
|
||||
|
||||
|
||||
@app.get("/async/model-no-response-model")
|
||||
async def async_model_no_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
|
||||
@app.get("/async/model-with-response-model", response_model=ItemOut)
|
||||
async def async_model_with_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def app(basemodel_class: type[Any]) -> FastAPI:
|
||||
class ItemIn(basemodel_class):
|
||||
name: str
|
||||
value: int
|
||||
|
||||
class ItemOut(basemodel_class):
|
||||
name: str
|
||||
value: int
|
||||
dep: int
|
||||
|
||||
class LargeIn(basemodel_class):
|
||||
items: list[dict[str, Any]]
|
||||
metadata: dict[str, Any]
|
||||
|
||||
class LargeOut(basemodel_class):
|
||||
items: list[dict[str, Any]]
|
||||
metadata: dict[str, Any]
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.filterwarnings(
|
||||
"ignore",
|
||||
message=r"pydantic\.v1 is deprecated and will soon stop being supported by FastAPI\..*",
|
||||
category=FastAPIDeprecationWarning,
|
||||
)
|
||||
|
||||
@app.post("/sync/validated", response_model=ItemOut)
|
||||
def sync_validated(item: ItemIn, dep: Annotated[int, Depends(dep_b)]):
|
||||
return ItemOut(name=item.name, value=item.value, dep=dep)
|
||||
|
||||
@app.get("/sync/dict-no-response-model")
|
||||
def sync_dict_no_response_model():
|
||||
return {"name": "foo", "value": 123}
|
||||
|
||||
@app.get("/sync/dict-with-response-model", response_model=ItemOut)
|
||||
def sync_dict_with_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return {"name": "foo", "value": 123, "dep": dep}
|
||||
|
||||
@app.get("/sync/model-no-response-model")
|
||||
def sync_model_no_response_model(dep: Annotated[int, Depends(dep_b)]):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
@app.get("/sync/model-with-response-model", response_model=ItemOut)
|
||||
def sync_model_with_response_model(dep: Annotated[int, Depends(dep_b)]):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
@app.post("/async/validated", response_model=ItemOut)
|
||||
async def async_validated(
|
||||
item: ItemIn,
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return ItemOut(name=item.name, value=item.value, dep=dep)
|
||||
|
||||
@app.post("/sync/large-receive")
|
||||
def sync_large_receive(payload: LargeIn):
|
||||
return {"received": len(payload.items)}
|
||||
|
||||
@app.post("/async/large-receive")
|
||||
async def async_large_receive(payload: LargeIn):
|
||||
return {"received": len(payload.items)}
|
||||
|
||||
@app.get("/sync/large-dict-no-response-model")
|
||||
def sync_large_dict_no_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
@app.get("/sync/large-dict-with-response-model", response_model=LargeOut)
|
||||
def sync_large_dict_with_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
@app.get("/sync/large-model-no-response-model")
|
||||
def sync_large_model_no_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
@app.get("/sync/large-model-with-response-model", response_model=LargeOut)
|
||||
def sync_large_model_with_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
@app.get("/async/large-dict-no-response-model")
|
||||
async def async_large_dict_no_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
@app.get("/async/large-dict-with-response-model", response_model=LargeOut)
|
||||
async def async_large_dict_with_response_model():
|
||||
return LARGE_PAYLOAD
|
||||
|
||||
@app.get("/async/large-model-no-response-model")
|
||||
async def async_large_model_no_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
@app.get("/async/large-model-with-response-model", response_model=LargeOut)
|
||||
async def async_large_model_with_response_model():
|
||||
return LargeOut(items=LARGE_ITEMS, metadata=LARGE_METADATA)
|
||||
|
||||
@app.get("/async/dict-no-response-model")
|
||||
async def async_dict_no_response_model():
|
||||
return {"name": "foo", "value": 123}
|
||||
|
||||
@app.get("/async/dict-with-response-model", response_model=ItemOut)
|
||||
async def async_dict_with_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return {"name": "foo", "value": 123, "dep": dep}
|
||||
|
||||
@app.get("/async/model-no-response-model")
|
||||
async def async_model_no_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
@app.get("/async/model-with-response-model", response_model=ItemOut)
|
||||
async def async_model_with_response_model(
|
||||
dep: Annotated[int, Depends(dep_b)],
|
||||
):
|
||||
return ItemOut(name="foo", value=123, dep=dep)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client(app: FastAPI) -> Iterator[TestClient]:
|
||||
def client() -> Iterator[TestClient]:
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
@@ -52,19 +51,13 @@ def test_openapi_schema():
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [
|
||||
{"$ref": "#/components/schemas/Foo"},
|
||||
{"type": "null"},
|
||||
],
|
||||
"title": "Foo",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"$ref": "#/components/schemas/Foo"}
|
||||
)
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{"$ref": "#/components/schemas/Foo"},
|
||||
{"type": "null"},
|
||||
],
|
||||
"title": "Foo",
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import APIRouter, FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
from pydantic import BaseModel, HttpUrl
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
@@ -32,121 +32,114 @@ client = TestClient(app)
|
||||
def test_openapi_schema():
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
"/": {
|
||||
"post": {
|
||||
"summary": "Main Route",
|
||||
"operationId": "main_route__post",
|
||||
"parameters": [
|
||||
{
|
||||
"required": True,
|
||||
"schema": IsDict(
|
||||
{
|
||||
"title": "Callback Url",
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
}
|
||||
)
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
| IsDict(
|
||||
{
|
||||
assert response.json() == snapshot(
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
"/": {
|
||||
"post": {
|
||||
"summary": "Main Route",
|
||||
"operationId": "main_route__post",
|
||||
"parameters": [
|
||||
{
|
||||
"required": True,
|
||||
"schema": {
|
||||
"title": "Callback Url",
|
||||
"maxLength": 2083,
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
}
|
||||
),
|
||||
"name": "callback_url",
|
||||
"in": "query",
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
},
|
||||
"name": "callback_url",
|
||||
"in": "query",
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
"callbacks": {
|
||||
"callback_route": {
|
||||
"{$callback_url}/callback/": {
|
||||
"get": {
|
||||
"summary": "Callback Route",
|
||||
"operationId": "callback_route__callback_url__callback__get",
|
||||
"responses": {
|
||||
"400": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CustomModel"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Bad Request",
|
||||
},
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {"schema": {}}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"CustomModel": {
|
||||
"title": "CustomModel",
|
||||
"required": ["a"],
|
||||
"type": "object",
|
||||
"properties": {"a": {"title": "A", "type": "integer"}},
|
||||
},
|
||||
"HTTPValidationError": {
|
||||
"title": "HTTPValidationError",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"detail": {
|
||||
"title": "Detail",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ValidationError"
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
"callbacks": {
|
||||
"callback_route": {
|
||||
"{$callback_url}/callback/": {
|
||||
"get": {
|
||||
"summary": "Callback Route",
|
||||
"operationId": "callback_route__callback_url__callback__get",
|
||||
"responses": {
|
||||
"400": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CustomModel"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Bad Request",
|
||||
},
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {"schema": {}}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
"ValidationError": {
|
||||
"title": "ValidationError",
|
||||
"required": ["loc", "msg", "type"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"loc": {
|
||||
"title": "Location",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [{"type": "string"}, {"type": "integer"}]
|
||||
},
|
||||
},
|
||||
"msg": {"title": "Message", "type": "string"},
|
||||
"type": {"title": "Error Type", "type": "string"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"CustomModel": {
|
||||
"title": "CustomModel",
|
||||
"required": ["a"],
|
||||
"type": "object",
|
||||
"properties": {"a": {"title": "A", "type": "integer"}},
|
||||
},
|
||||
"HTTPValidationError": {
|
||||
"title": "HTTPValidationError",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"detail": {
|
||||
"title": "Detail",
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/components/schemas/ValidationError"},
|
||||
}
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
"title": "ValidationError",
|
||||
"required": ["loc", "msg", "type"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"loc": {
|
||||
"title": "Location",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [{"type": "string"}, {"type": "integer"}]
|
||||
},
|
||||
},
|
||||
"msg": {"title": "Message", "type": "string"},
|
||||
"type": {"title": "Error Type", "type": "string"},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from typing import Annotated
|
||||
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import APIRouter, FastAPI, Query
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
@@ -32,44 +31,23 @@ client = TestClient(app)
|
||||
|
||||
foo_is_missing = {
|
||||
"detail": [
|
||||
IsDict(
|
||||
{
|
||||
"loc": ["query", "foo"],
|
||||
"msg": "Field required",
|
||||
"type": "missing",
|
||||
"input": None,
|
||||
}
|
||||
)
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
| IsDict(
|
||||
{
|
||||
"loc": ["query", "foo"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
)
|
||||
{
|
||||
"loc": ["query", "foo"],
|
||||
"msg": "Field required",
|
||||
"type": "missing",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
foo_is_short = {
|
||||
"detail": [
|
||||
IsDict(
|
||||
{
|
||||
"ctx": {"min_length": 1},
|
||||
"loc": ["query", "foo"],
|
||||
"msg": "String should have at least 1 character",
|
||||
"type": "string_too_short",
|
||||
"input": "",
|
||||
}
|
||||
)
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
| IsDict(
|
||||
{
|
||||
"ctx": {"limit_value": 1},
|
||||
"loc": ["query", "foo"],
|
||||
"msg": "ensure this value has at least 1 characters",
|
||||
"type": "value_error.any_str.min_length",
|
||||
}
|
||||
)
|
||||
{
|
||||
"ctx": {"min_length": 1},
|
||||
"loc": ["query", "foo"],
|
||||
"msg": "String should have at least 1 character",
|
||||
"type": "string_too_short",
|
||||
"input": "",
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from .main import app
|
||||
@@ -274,14 +273,10 @@ def test_openapi_schema():
|
||||
"name": "item_id",
|
||||
"in": "path",
|
||||
"required": True,
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "Item Id",
|
||||
}
|
||||
)
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
| IsDict({"title": "Item Id", "type": "string"}),
|
||||
"schema": {
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "Item Id",
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
@@ -984,14 +979,10 @@ def test_openapi_schema():
|
||||
"name": "query",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
"title": "Query",
|
||||
}
|
||||
)
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
| IsDict({"title": "Query", "type": "integer"}),
|
||||
"schema": {
|
||||
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
||||
"title": "Query",
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
from typing import Any, Union
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI, UploadFile
|
||||
from fastapi._compat import (
|
||||
Undefined,
|
||||
_get_model_config,
|
||||
get_cached_model_fields,
|
||||
is_scalar_field,
|
||||
is_uploadfile_sequence_annotation,
|
||||
may_v1,
|
||||
)
|
||||
from fastapi._compat.shared import is_bytes_sequence_annotation
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.fields import FieldInfo
|
||||
|
||||
from .utils import needs_py310, needs_py_lt_314
|
||||
from .utils import needs_py310
|
||||
|
||||
|
||||
def test_model_field_default_required():
|
||||
@@ -26,35 +22,6 @@ def test_model_field_default_required():
|
||||
assert field.default is Undefined
|
||||
|
||||
|
||||
@needs_py_lt_314
|
||||
def test_v1_plain_validator_function():
|
||||
from fastapi._compat import v1
|
||||
|
||||
# For coverage
|
||||
def func(v): # pragma: no cover
|
||||
return v
|
||||
|
||||
result = v1.with_info_plain_validator_function(func)
|
||||
assert result == {}
|
||||
|
||||
|
||||
def test_is_model_field():
|
||||
# For coverage
|
||||
from fastapi._compat import _is_model_field
|
||||
|
||||
assert not _is_model_field(str)
|
||||
|
||||
|
||||
def test_get_model_config():
|
||||
# For coverage in Pydantic v2
|
||||
class Foo(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
foo = Foo()
|
||||
config = _get_model_config(foo)
|
||||
assert config == {"from_attributes": True}
|
||||
|
||||
|
||||
def test_complex():
|
||||
app = FastAPI()
|
||||
|
||||
@@ -165,33 +132,3 @@ def test_serialize_sequence_value_with_none_first_in_union():
|
||||
result = v2.serialize_sequence_value(field=field, value=["x", "y"])
|
||||
assert result == ["x", "y"]
|
||||
assert isinstance(result, list)
|
||||
|
||||
|
||||
@needs_py_lt_314
|
||||
def test_is_pv1_scalar_field():
|
||||
from fastapi._compat import v1
|
||||
|
||||
# For coverage
|
||||
class Model(v1.BaseModel):
|
||||
foo: Union[str, dict[str, Any]]
|
||||
|
||||
fields = v1.get_model_fields(Model)
|
||||
assert not is_scalar_field(fields[0])
|
||||
|
||||
|
||||
@needs_py_lt_314
|
||||
def test_get_model_fields_cached():
|
||||
from fastapi._compat import v1
|
||||
|
||||
class Model(may_v1.BaseModel):
|
||||
foo: str
|
||||
|
||||
non_cached_fields = v1.get_model_fields(Model)
|
||||
non_cached_fields2 = v1.get_model_fields(Model)
|
||||
cached_fields = get_cached_model_fields(Model)
|
||||
cached_fields2 = get_cached_model_fields(Model)
|
||||
for f1, f2 in zip(cached_fields, cached_fields2):
|
||||
assert f1 is f2
|
||||
|
||||
assert non_cached_fields is not non_cached_fields2
|
||||
assert cached_fields is cached_fields2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,9 @@
|
||||
import warnings
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .utils import needs_pydanticv1
|
||||
|
||||
|
||||
def test_pydanticv2():
|
||||
from pydantic import field_serializer
|
||||
@@ -29,34 +26,3 @@ def test_pydanticv2():
|
||||
with client:
|
||||
response = client.get("/model")
|
||||
assert response.json() == {"dt_field": "2019-01-01T08:00:00+00:00"}
|
||||
|
||||
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
@needs_pydanticv1
|
||||
def test_pydanticv1():
|
||||
from pydantic import v1
|
||||
|
||||
class ModelWithDatetimeField(v1.BaseModel):
|
||||
dt_field: datetime
|
||||
|
||||
class Config:
|
||||
json_encoders = {
|
||||
datetime: lambda dt: dt.replace(
|
||||
microsecond=0, tzinfo=timezone.utc
|
||||
).isoformat()
|
||||
}
|
||||
|
||||
app = FastAPI()
|
||||
model = ModelWithDatetimeField(dt_field=datetime(2019, 1, 1, 8))
|
||||
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
|
||||
@app.get("/model", response_model=ModelWithDatetimeField)
|
||||
def get_model():
|
||||
return model
|
||||
|
||||
client = TestClient(app)
|
||||
with client:
|
||||
response = client.get("/model")
|
||||
assert response.json() == {"dt_field": "2019-01-01T08:00:00+00:00"}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import BaseModel
|
||||
@@ -46,29 +45,16 @@ async def no_duplicates_sub(
|
||||
def test_no_duplicates_invalid():
|
||||
response = client.post("/no-duplicates", json={"item": {"data": "myitem"}})
|
||||
assert response.status_code == 422, response.text
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["body", "item2"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["body", "item2"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["body", "item2"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_no_duplicates():
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import APIRouter, Depends, FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
@@ -54,29 +53,16 @@ async def overrider_dependency_with_sub(msg: dict = Depends(overrider_sub_depend
|
||||
def test_main_depends():
|
||||
response = client.get("/main-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "q"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_main_depends_q_foo():
|
||||
@@ -100,29 +86,16 @@ def test_main_depends_q_foo_skip_100_limit_200():
|
||||
def test_decorator_depends():
|
||||
response = client.get("/decorator-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "q"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_decorator_depends_q_foo():
|
||||
@@ -140,29 +113,16 @@ def test_decorator_depends_q_foo_skip_100_limit_200():
|
||||
def test_router_depends():
|
||||
response = client.get("/router-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "q"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_router_depends_q_foo():
|
||||
@@ -186,29 +146,16 @@ def test_router_depends_q_foo_skip_100_limit_200():
|
||||
def test_router_decorator_depends():
|
||||
response = client.get("/router-decorator-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "q"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "q"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_router_decorator_depends_q_foo():
|
||||
@@ -272,29 +219,17 @@ def test_override_with_sub_main_depends():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/main-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
@@ -302,29 +237,17 @@ def test_override_with_sub__main_depends_q_foo():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/main-depends/?q=foo")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
@@ -340,29 +263,17 @@ def test_override_with_sub_decorator_depends():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/decorator-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
@@ -370,29 +281,17 @@ def test_override_with_sub_decorator_depends_q_foo():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/decorator-depends/?q=foo")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
@@ -408,29 +307,17 @@ def test_override_with_sub_router_depends():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/router-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
@@ -438,29 +325,17 @@ def test_override_with_sub_router_depends_q_foo():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/router-depends/?q=foo")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
@@ -476,29 +351,17 @@ def test_override_with_sub_router_decorator_depends():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/router-decorator-depends/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
@@ -506,29 +369,17 @@ def test_override_with_sub_router_decorator_depends_q_foo():
|
||||
app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
|
||||
response = client.get("/router-decorator-depends/?q=foo")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["query", "k"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["query", "k"],
|
||||
"msg": "Field required",
|
||||
"input": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
app.dependency_overrides = {}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.testclient import TestClient
|
||||
@@ -328,14 +327,10 @@ def test_openapi_schema():
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"price": IsDict(
|
||||
{
|
||||
"title": "Price",
|
||||
"anyOf": [{"type": "number"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
| IsDict({"title": "Price", "type": "number"}),
|
||||
"price": {
|
||||
"title": "Price",
|
||||
"anyOf": [{"type": "number"}, {"type": "null"}],
|
||||
},
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import warnings
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Depends, FastAPI
|
||||
from pydantic.v1 import BaseModel, validator
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class ModelB(BaseModel):
|
||||
username: str
|
||||
|
||||
|
||||
class ModelC(ModelB):
|
||||
password: str
|
||||
|
||||
|
||||
class ModelA(BaseModel):
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
model_b: ModelB
|
||||
tags: dict[str, str] = {}
|
||||
|
||||
@validator("name")
|
||||
def lower_username(cls, name: str, values):
|
||||
if not name.endswith("A"):
|
||||
raise ValueError("name must end in A")
|
||||
return name
|
||||
|
||||
|
||||
async def get_model_c() -> ModelC:
|
||||
return ModelC(username="test-user", password="test-password")
|
||||
|
||||
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
|
||||
@app.get("/model/{name}", response_model=ModelA)
|
||||
async def get_model_a(name: str, model_c=Depends(get_model_c)):
|
||||
return {
|
||||
"name": name,
|
||||
"description": "model-a-desc",
|
||||
"model_b": model_c,
|
||||
"tags": {"key1": "value1", "key2": "value2"},
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
import pytest
|
||||
from fastapi.exceptions import ResponseValidationError
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from ..utils import needs_pydanticv1
|
||||
|
||||
|
||||
@pytest.fixture(name="client")
|
||||
def get_client():
|
||||
from .app_pv1 import app
|
||||
|
||||
client = TestClient(app)
|
||||
return client
|
||||
|
||||
|
||||
@needs_pydanticv1
|
||||
def test_filter_sub_model(client: TestClient):
|
||||
response = client.get("/model/modelA")
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {
|
||||
"name": "modelA",
|
||||
"description": "model-a-desc",
|
||||
"model_b": {"username": "test-user"},
|
||||
"tags": {"key1": "value1", "key2": "value2"},
|
||||
}
|
||||
|
||||
|
||||
@needs_pydanticv1
|
||||
def test_validator_is_cloned(client: TestClient):
|
||||
with pytest.raises(ResponseValidationError) as err:
|
||||
client.get("/model/modelX")
|
||||
assert err.value.errors() == [
|
||||
{
|
||||
"loc": ("response", "name"),
|
||||
"msg": "name must end in A",
|
||||
"type": "value_error",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@needs_pydanticv1
|
||||
def test_openapi_schema(client: TestClient):
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == snapshot(
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
"/model/{name}": {
|
||||
"get": {
|
||||
"summary": "Get Model A",
|
||||
"operationId": "get_model_a_model__name__get",
|
||||
"parameters": [
|
||||
{
|
||||
"required": True,
|
||||
"schema": {"title": "Name", "type": "string"},
|
||||
"name": "name",
|
||||
"in": "path",
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelA"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"HTTPValidationError": {
|
||||
"title": "HTTPValidationError",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"detail": {
|
||||
"title": "Detail",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ValidationError"
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
"ModelA": {
|
||||
"title": "ModelA",
|
||||
"required": ["name", "model_b"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"description": {"title": "Description", "type": "string"},
|
||||
"model_b": {"$ref": "#/components/schemas/ModelB"},
|
||||
"tags": {
|
||||
"additionalProperties": {"type": "string"},
|
||||
"type": "object",
|
||||
"title": "Tags",
|
||||
"default": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
"ModelB": {
|
||||
"title": "ModelB",
|
||||
"required": ["username"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {"title": "Username", "type": "string"}
|
||||
},
|
||||
},
|
||||
"ValidationError": {
|
||||
"title": "ValidationError",
|
||||
"required": ["loc", "msg", "type"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"loc": {
|
||||
"title": "Location",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [{"type": "string"}, {"type": "integer"}]
|
||||
},
|
||||
},
|
||||
"msg": {"title": "Message", "type": "string"},
|
||||
"type": {"title": "Error Type", "type": "string"},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
from dirty_equals import HasRepr, IsDict, IsOneOf
|
||||
from dirty_equals import HasRepr
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.exceptions import ResponseValidationError
|
||||
from fastapi.testclient import TestClient
|
||||
@@ -63,23 +63,13 @@ def test_validator_is_cloned(client: TestClient):
|
||||
with pytest.raises(ResponseValidationError) as err:
|
||||
client.get("/model/modelX")
|
||||
assert err.value.errors() == [
|
||||
IsDict(
|
||||
{
|
||||
"type": "value_error",
|
||||
"loc": ("response", "name"),
|
||||
"msg": "Value error, name must end in A",
|
||||
"input": "modelX",
|
||||
"ctx": {"error": HasRepr("ValueError('name must end in A')")},
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
{
|
||||
"loc": ("response", "name"),
|
||||
"msg": "name must end in A",
|
||||
"type": "value_error",
|
||||
}
|
||||
)
|
||||
{
|
||||
"type": "value_error",
|
||||
"loc": ("response", "name"),
|
||||
"msg": "Value error, name must end in A",
|
||||
"input": "modelX",
|
||||
"ctx": {"error": HasRepr("ValueError('name must end in A')")},
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -145,23 +135,14 @@ def test_openapi_schema(client: TestClient):
|
||||
},
|
||||
"ModelA": {
|
||||
"title": "ModelA",
|
||||
"required": IsOneOf(
|
||||
["name", "description", "foo"],
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
["name", "foo"],
|
||||
),
|
||||
"required": ["name", "foo"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"title": "Name", "type": "string"},
|
||||
"description": IsDict(
|
||||
{
|
||||
"title": "Description",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
}
|
||||
)
|
||||
|
|
||||
# TODO remove when deprecating Pydantic v1
|
||||
IsDict({"title": "Description", "type": "string"}),
|
||||
"description": {
|
||||
"title": "Description",
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
},
|
||||
"foo": {"$ref": "#/components/schemas/ModelB"},
|
||||
"tags": {
|
||||
"additionalProperties": {"type": "string"},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import Annotated, Optional
|
||||
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import FastAPI, Form
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import BaseModel, Field
|
||||
@@ -79,68 +78,37 @@ def test_invalid_data():
|
||||
},
|
||||
)
|
||||
assert response.status_code == 422, response.text
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "int_parsing",
|
||||
"loc": ["body", "age"],
|
||||
"msg": "Input should be a valid integer, unable to parse string as an integer",
|
||||
"input": "seventy",
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["body", "age"],
|
||||
"msg": "value is not a valid integer",
|
||||
"type": "type_error.integer",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "int_parsing",
|
||||
"loc": ["body", "age"],
|
||||
"msg": "Input should be a valid integer, unable to parse string as an integer",
|
||||
"input": "seventy",
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_no_data():
|
||||
response = client.post("/form/")
|
||||
assert response.status_code == 422, response.text
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["body", "username"],
|
||||
"msg": "Field required",
|
||||
"input": {"tags": ["foo", "bar"], "with": "nothing"},
|
||||
},
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["body", "lastname"],
|
||||
"msg": "Field required",
|
||||
"input": {"tags": ["foo", "bar"], "with": "nothing"},
|
||||
},
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["body", "username"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
},
|
||||
{
|
||||
"loc": ["body", "lastname"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
},
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["body", "username"],
|
||||
"msg": "Field required",
|
||||
"input": {"tags": ["foo", "bar"], "with": "nothing"},
|
||||
},
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["body", "lastname"],
|
||||
"msg": "Field required",
|
||||
"input": {"tags": ["foo", "bar"], "with": "nothing"},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_extra_param_single():
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from .utils import needs_pydanticv1
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("pydantic-v1", marks=needs_pydanticv1),
|
||||
"pydantic-v2",
|
||||
],
|
||||
)
|
||||
def client_fixture(request: pytest.FixtureRequest) -> TestClient:
|
||||
if request.param == "pydantic-v1":
|
||||
from pydantic.v1 import BaseModel
|
||||
else:
|
||||
from pydantic import BaseModel
|
||||
@pytest.fixture(name="client")
|
||||
def client_fixture() -> TestClient:
|
||||
from pydantic import BaseModel
|
||||
|
||||
class Address(BaseModel):
|
||||
"""
|
||||
@@ -38,28 +25,12 @@ def client_fixture(request: pytest.FixtureRequest) -> TestClient:
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
if request.param == "pydantic-v1":
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
|
||||
@app.get("/facilities/{facility_id}")
|
||||
def get_facility(facility_id: str) -> Facility:
|
||||
return Facility(
|
||||
id=facility_id,
|
||||
address=Address(
|
||||
line_1="123 Main St", city="Anytown", state_province="CA"
|
||||
),
|
||||
)
|
||||
else:
|
||||
|
||||
@app.get("/facilities/{facility_id}")
|
||||
def get_facility(facility_id: str) -> Facility:
|
||||
return Facility(
|
||||
id=facility_id,
|
||||
address=Address(
|
||||
line_1="123 Main St", city="Anytown", state_province="CA"
|
||||
),
|
||||
)
|
||||
@app.get("/facilities/{facility_id}")
|
||||
def get_facility(facility_id: str) -> Facility:
|
||||
return Facility(
|
||||
id=facility_id,
|
||||
address=Address(line_1="123 Main St", city="Anytown", state_province="CA"),
|
||||
)
|
||||
|
||||
client = TestClient(app)
|
||||
return client
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import APIRouter, FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
@@ -163,16 +162,10 @@ def test_openapi_schema():
|
||||
"required": False,
|
||||
"name": "user_id",
|
||||
"in": "query",
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "User Id", "type": "string"}
|
||||
),
|
||||
"schema": {
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
},
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -208,16 +201,10 @@ def test_openapi_schema():
|
||||
"required": False,
|
||||
"name": "user_id",
|
||||
"in": "query",
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "User Id", "type": "string"}
|
||||
),
|
||||
"schema": {
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
},
|
||||
},
|
||||
],
|
||||
"responses": {
|
||||
@@ -247,16 +234,10 @@ def test_openapi_schema():
|
||||
"required": True,
|
||||
"name": "user_id",
|
||||
"in": "path",
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "User Id", "type": "string"}
|
||||
),
|
||||
"schema": {
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
},
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -292,16 +273,10 @@ def test_openapi_schema():
|
||||
"required": True,
|
||||
"name": "user_id",
|
||||
"in": "path",
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{"title": "User Id", "type": "string"}
|
||||
),
|
||||
"schema": {
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "User Id",
|
||||
},
|
||||
},
|
||||
],
|
||||
"responses": {
|
||||
|
||||
@@ -5,8 +5,6 @@ from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .utils import needs_pydanticv1
|
||||
|
||||
|
||||
class MyUuid:
|
||||
def __init__(self, uuid_string: str):
|
||||
@@ -67,46 +65,3 @@ def test_pydanticv2():
|
||||
assert response_pydantic.json() == {
|
||||
"a_uuid": "b8799909-f914-42de-91bc-95c819218d01"
|
||||
}
|
||||
|
||||
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
@needs_pydanticv1
|
||||
def test_pydanticv1():
|
||||
from pydantic import v1
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.get("/fast_uuid")
|
||||
def return_fast_uuid():
|
||||
asyncpg_uuid = MyUuid("a10ff360-3b1e-4984-a26f-d3ab460bdb51")
|
||||
assert isinstance(asyncpg_uuid, uuid.UUID)
|
||||
assert type(asyncpg_uuid) is not uuid.UUID
|
||||
with pytest.raises(TypeError):
|
||||
vars(asyncpg_uuid)
|
||||
return {"fast_uuid": asyncpg_uuid}
|
||||
|
||||
class SomeCustomClass(v1.BaseModel):
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
json_encoders = {uuid.UUID: str}
|
||||
|
||||
a_uuid: MyUuid
|
||||
|
||||
@app.get("/get_custom_class")
|
||||
def return_some_user():
|
||||
# Test that the fix also works for custom pydantic classes
|
||||
return SomeCustomClass(a_uuid=MyUuid("b8799909-f914-42de-91bc-95c819218d01"))
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
with client:
|
||||
response_simple = client.get("/fast_uuid")
|
||||
response_pydantic = client.get("/get_custom_class")
|
||||
|
||||
assert response_simple.json() == {
|
||||
"fast_uuid": "a10ff360-3b1e-4984-a26f-d3ab460bdb51"
|
||||
}
|
||||
|
||||
assert response_pydantic.json() == {
|
||||
"a_uuid": "b8799909-f914-42de-91bc-95c819218d01"
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user