Skip to content

Commit

Permalink
⬆️ Drop support for Python 3.7, require Python 3.8 or above (#10442)
Browse files Browse the repository at this point in the history
* 📝 Update docs, require Python 3.8+, drop 3.7

* 🔧 Update pyproject.toml, drop support for Python 3.7, require Python 3.8+

* 👷 Update CI GitHub Actions, drop support for Python 3.7, require 3.8+

* 📝 Update docs' references to Python 3.6 and 3.7, use Python 3.8
  • Loading branch information
tiangolo committed Oct 17, 2023
1 parent c1adce4 commit 2ba7586
Show file tree
Hide file tree
Showing 120 changed files with 657 additions and 658 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.10"
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
cache-dependency-path: pyproject.toml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
pydantic-version: ["pydantic-v1", "pydantic-v2"]
fail-fast: false
steps:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -27,7 +27,7 @@

---

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python type hints.

The key features are:

Expand Down Expand Up @@ -120,7 +120,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be

## Requirements

Python 3.7+
Python 3.8+

FastAPI stands on the shoulders of giants:

Expand Down Expand Up @@ -336,7 +336,7 @@ You do that with standard modern Python types.

You don't have to learn a new syntax, the methods or classes of a specific library, etc.

Just standard **Python 3.7+**.
Just standard **Python 3.8+**.

For example, for an `int`:

Expand Down
2 changes: 1 addition & 1 deletion docs/de/docs/features.md
Expand Up @@ -25,7 +25,7 @@ Mit einer interaktiven API-Dokumentation und explorativen webbasierten Benutzers

### Nur modernes Python

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



Expand Down
4 changes: 2 additions & 2 deletions docs/en/docs/advanced/additional-status-codes.md
Expand Up @@ -26,7 +26,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
{!> ../../../docs_src/additional_status_codes/tutorial001_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="4 26"
{!> ../../../docs_src/additional_status_codes/tutorial001_an.py!}
Expand All @@ -41,7 +41,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
{!> ../../../docs_src/additional_status_codes/tutorial001_py310.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down
16 changes: 8 additions & 8 deletions docs/en/docs/advanced/advanced-dependencies.md
Expand Up @@ -24,13 +24,13 @@ To do that, we declare a method `__call__`:
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand All @@ -51,13 +51,13 @@ And now, we can use `__init__` to declare the parameters of the instance that we
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="8"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand All @@ -78,13 +78,13 @@ We could create an instance of this class with:
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -113,13 +113,13 @@ checker(q="somequery")
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="21"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down
6 changes: 3 additions & 3 deletions docs/en/docs/advanced/generate-clients.md
Expand Up @@ -35,7 +35,7 @@ Let's start with a simple FastAPI application:
{!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="9-11 14-15 18 19 23"
{!> ../../../docs_src/generate_clients/tutorial001.py!}
Expand Down Expand Up @@ -147,7 +147,7 @@ For example, you could have a section for **items** and another section for **us
{!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="23 28 36"
{!> ../../../docs_src/generate_clients/tutorial002.py!}
Expand Down Expand Up @@ -204,7 +204,7 @@ You can then pass that custom function to **FastAPI** as the `generate_unique_id
{!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="8-9 12"
{!> ../../../docs_src/generate_clients/tutorial003.py!}
Expand Down
12 changes: 6 additions & 6 deletions docs/en/docs/advanced/security/http-basic-auth.md
Expand Up @@ -26,13 +26,13 @@ Then, when you type that username and password, the browser sends them in the he
{!> ../../../docs_src/security/tutorial006_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="2 7 11"
{!> ../../../docs_src/security/tutorial006_an.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -65,13 +65,13 @@ Then we can use `secrets.compare_digest()` to ensure that `credentials.username`
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="1 12-24"
{!> ../../../docs_src/security/tutorial007_an.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -148,13 +148,13 @@ After detecting that the credentials are incorrect, return an `HTTPException` wi
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="26-30"
{!> ../../../docs_src/security/tutorial007_an.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down
32 changes: 16 additions & 16 deletions docs/en/docs/advanced/security/oauth2-scopes.md
Expand Up @@ -68,7 +68,7 @@ First, let's quickly see the parts that change from the examples in the main **T
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="2 4 8 12 47 65 106 108-116 122-125 129-135 140 156"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -92,7 +92,7 @@ First, let's quickly see the parts that change from the examples in the main **T
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -121,7 +121,7 @@ The `scopes` parameter receives a `dict` with each scope as a key and the descri
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="63-66"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -146,7 +146,7 @@ The `scopes` parameter receives a `dict` with each scope as a key and the descri
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -188,7 +188,7 @@ And we return the scopes as part of the JWT token.
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="156"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -212,7 +212,7 @@ And we return the scopes as part of the JWT token.
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -254,7 +254,7 @@ In this case, it requires the scope `me` (it could require more than one scope).
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="4 140 171"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -278,7 +278,7 @@ In this case, it requires the scope `me` (it could require more than one scope).
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -320,7 +320,7 @@ This `SecurityScopes` class is similar to `Request` (`Request` was used to get t
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="8 106"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -344,7 +344,7 @@ This `SecurityScopes` class is similar to `Request` (`Request` was used to get t
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -377,7 +377,7 @@ In this exception, we include the scopes required (if any) as a string separated
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="106 108-116"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -401,7 +401,7 @@ In this exception, we include the scopes required (if any) as a string separated
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down Expand Up @@ -436,7 +436,7 @@ We also verify that we have a user with that username, and if not, we raise that
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="47 117-128"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -460,7 +460,7 @@ We also verify that we have a user with that username, and if not, we raise that
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand All @@ -487,7 +487,7 @@ For this, we use `security_scopes.scopes`, that contains a `list` with all these
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```

=== "Python 3.6+"
=== "Python 3.8+"

```Python hl_lines="129-135"
{!> ../../../docs_src/security/tutorial005_an.py!}
Expand All @@ -511,7 +511,7 @@ For this, we use `security_scopes.scopes`, that contains a `list` with all these
{!> ../../../docs_src/security/tutorial005_py39.py!}
```

=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"

!!! tip
Prefer to use the `Annotated` version if possible.
Expand Down

0 comments on commit 2ba7586

Please sign in to comment.