Skip to content

Commit a47b544

Browse files
authored
Merge branch 'main' into disable-uvicorn-logger-propagation
2 parents be7b699 + ccec548 commit a47b544

25 files changed

+2265
-119
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ updates:
88
commit-message:
99
prefix:
1010
# Python
11-
- package-ecosystem: "pip"
11+
- package-ecosystem: "uv"
1212
directory: "/"
1313
schedule:
1414
interval: "daily"

.github/workflows/pre-commit.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
env:
10+
# Forks and Dependabot don't have access to secrets
11+
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
12+
13+
jobs:
14+
pre-commit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Dump GitHub context
18+
env:
19+
GITHUB_CONTEXT: ${{ toJson(github) }}
20+
run: echo "$GITHUB_CONTEXT"
21+
- uses: actions/checkout@v6
22+
name: Checkout PR for own repo
23+
if: env.HAS_SECRETS == 'true'
24+
with:
25+
# To be able to commit it needs to fetch the head of the branch, not the
26+
# merge commit
27+
ref: ${{ github.head_ref }}
28+
# And it needs the full history to be able to compute diffs
29+
fetch-depth: 0
30+
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
31+
token: ${{ secrets.PRE_COMMIT }}
32+
# pre-commit lite ci needs the default checkout configs to work
33+
- uses: actions/checkout@v6
34+
name: Checkout PR for fork
35+
if: env.HAS_SECRETS == 'false'
36+
with:
37+
# To be able to commit it needs the head branch of the PR, the remote one
38+
ref: ${{ github.event.pull_request.head.sha }}
39+
fetch-depth: 0
40+
- name: Set up Python
41+
uses: actions/setup-python@v6
42+
with:
43+
python-version-file: ".python-version"
44+
- name: Setup uv
45+
uses: astral-sh/setup-uv@v7
46+
with:
47+
cache-dependency-glob: |
48+
pyproject.toml
49+
uv.lock
50+
- name: Install Dependencies
51+
run: uv sync --locked
52+
- name: Run prek - pre-commit
53+
id: precommit
54+
run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
55+
continue-on-error: true
56+
- name: Commit and push changes
57+
if: env.HAS_SECRETS == 'true'
58+
run: |
59+
git config user.name "github-actions[bot]"
60+
git config user.email "github-actions[bot]@users.noreply.github.com"
61+
git add -A
62+
if git diff --staged --quiet; then
63+
echo "No changes to commit"
64+
else
65+
git commit -m "🎨 Auto format"
66+
git push
67+
fi
68+
- uses: pre-commit-ci/[email protected]
69+
if: env.HAS_SECRETS == 'false'
70+
with:
71+
msg: 🎨 Auto format
72+
- name: Error out on pre-commit errors
73+
if: steps.precommit.outcome == 'failure'
74+
run: exit 1
75+
76+
# https://github.com/marketplace/actions/alls-green#why
77+
pre-commit-alls-green: # This job does nothing and is only used for the branch protection
78+
if: always()
79+
needs:
80+
- pre-commit
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Dump GitHub context
84+
env:
85+
GITHUB_CONTEXT: ${{ toJson(github) }}
86+
run: echo "$GITHUB_CONTEXT"
87+
- name: Decide whether the needed jobs succeeded or failed
88+
uses: re-actors/alls-green@release/v1
89+
with:
90+
jobs: ${{ toJSON(needs) }}

.github/workflows/publish.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- fastapi-cli
1616
permissions:
1717
id-token: write
18+
contents: read
1819
steps:
1920
- name: Dump GitHub context
2021
env:
@@ -24,15 +25,12 @@ jobs:
2425
- name: Set up Python
2526
uses: actions/setup-python@v6
2627
with:
27-
python-version: "3.10"
28-
# Issue ref: https://github.com/actions/setup-python/issues/436
29-
# cache: "pip"
30-
# cache-dependency-path: pyproject.toml
31-
- name: Install build dependencies
32-
run: pip install build
28+
python-version-file: ".python-version"
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v7
3331
- name: Build distribution
32+
run: uv build
3433
env:
3534
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
36-
run: python -m build
3735
- name: Publish
38-
uses: pypa/gh-action-pypi-publish@v1.13.0
36+
run: uv publish

.github/workflows/smokeshow.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ on:
88
permissions:
99
statuses: write
1010

11-
env:
12-
UV_SYSTEM_PYTHON: 1
13-
1411
jobs:
1512
smokeshow:
16-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1713
runs-on: ubuntu-latest
1814
steps:
1915
- name: Dump GitHub context
@@ -23,23 +19,21 @@ jobs:
2319
- uses: actions/checkout@v6
2420
- uses: actions/setup-python@v6
2521
with:
26-
python-version: '3.9'
22+
python-version-file: ".python-version"
2723
- name: Setup uv
2824
uses: astral-sh/setup-uv@v7
2925
with:
30-
version: "0.4.15"
31-
enable-cache: true
3226
cache-dependency-glob: |
33-
requirements**.txt
3427
pyproject.toml
35-
- run: uv pip install -r requirements-github-actions.txt
36-
- uses: actions/download-artifact@v6
28+
uv.lock
29+
- run: uv sync --locked --no-dev --group github-actions
30+
- uses: actions/download-artifact@v7
3731
with:
3832
name: coverage-html
3933
path: htmlcov
4034
github-token: ${{ secrets.GITHUB_TOKEN }}
4135
run-id: ${{ github.event.workflow_run.id }}
42-
- run: smokeshow upload htmlcov
36+
- run: uv run smokeshow upload htmlcov
4337
env:
4438
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
4539
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100

.github/workflows/test-redistribute.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set up Python
2727
uses: actions/setup-python@v6
2828
with:
29-
python-version: "3.10"
29+
python-version-file: ".python-version"
3030
# Issue ref: https://github.com/actions/setup-python/issues/436
3131
# cache: "pip"
3232
# cache-dependency-path: pyproject.toml
@@ -43,7 +43,7 @@ jobs:
4343
- name: Install test dependencies
4444
run: |
4545
cd dist/fastapi_cli*/
46-
pip install -r requirements-tests.txt
46+
pip install --group tests --editable .[standard]
4747
env:
4848
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
4949
- name: Run source distribution tests

.github/workflows/test.yml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,31 @@ on:
2222
default: 'false'
2323

2424
env:
25-
UV_SYSTEM_PYTHON: 1
25+
UV_NO_SYNC: true
2626

2727
jobs:
2828
test:
2929
strategy:
3030
matrix:
3131
os: [ ubuntu-latest, windows-latest, macos-latest ]
3232
python-version: ["3.14"]
33-
pydantic-version: ["v2"]
3433
include:
35-
- python-version: "3.8"
36-
pydantic-version: "v1"
37-
os: windows-latest
3834
- python-version: "3.9"
39-
pydantic-version: "v2"
4035
os: macos-latest
4136
- python-version: "3.10"
42-
pydantic-version: "v1"
4337
os: ubuntu-latest
4438
- python-version: "3.11"
45-
pydantic-version: "v2"
4639
os: windows-latest
4740
- python-version: "3.12"
48-
pydantic-version: "v1"
4941
os: macos-latest
5042
- python-version: "3.13"
51-
pydantic-version: "v1"
5243
os: ubuntu-latest
5344
- python-version: "3.13"
54-
pydantic-version: "v2"
5545
os: windows-latest
5646
fail-fast: false
5747
runs-on: ${{ matrix.os }}
48+
env:
49+
UV_PYTHON: ${{ matrix.python-version }}
5850
steps:
5951
- name: Dump GitHub context
6052
env:
@@ -68,34 +60,28 @@ jobs:
6860
- name: Setup uv
6961
uses: astral-sh/setup-uv@v7
7062
with:
71-
version: "0.4.15"
7263
enable-cache: true
7364
cache-dependency-glob: |
74-
requirements**.txt
7565
pyproject.toml
66+
uv.lock
7667
# Allow debugging with tmate
7768
- name: Setup tmate session
7869
uses: mxschmitt/action-tmate@v3
7970
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
8071
with:
8172
limit-access-to-actor: true
8273
- name: Install Dependencies
83-
run: uv pip install -r requirements-tests.txt
84-
- name: Install Pydantic v1
85-
if: matrix.pydantic-version == 'v1'
86-
run: uv pip install "pydantic<2.0.0"
87-
- name: Lint
88-
run: bash scripts/lint.sh
74+
run: uv sync --locked --no-dev --group tests --extra standard
8975
- run: mkdir coverage
9076
- name: Test
91-
run: bash scripts/test.sh
77+
run: uv run bash scripts/test.sh
9278
env:
93-
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
94-
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
79+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
80+
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
9581
- name: Store coverage files
96-
uses: actions/upload-artifact@v5
82+
uses: actions/upload-artifact@v6
9783
with:
98-
name: coverage-${{ runner.os }}-${{ matrix.python-version }}-pydantic-${{ matrix.pydantic-version }}
84+
name: coverage-${{ runner.os }}-${{ matrix.python-version }}
9985
path: coverage
10086
include-hidden-files: true
10187

@@ -110,32 +96,32 @@ jobs:
11096
- uses: actions/checkout@v6
11197
- uses: actions/setup-python@v6
11298
with:
113-
python-version: '3.8'
99+
python-version-file: ".python-version"
114100
- name: Setup uv
115101
uses: astral-sh/setup-uv@v7
116102
with:
117-
version: "0.4.15"
118103
enable-cache: true
119104
cache-dependency-glob: |
120-
requirements**.txt
121105
pyproject.toml
106+
uv.lock
122107
- name: Get coverage files
123-
uses: actions/download-artifact@v6
108+
uses: actions/download-artifact@v7
124109
with:
125110
pattern: coverage-*
126111
path: coverage
127112
merge-multiple: true
128-
- run: uv pip install -r requirements-tests.txt
113+
- name: Install dependencies
114+
run: uv sync --locked --no-dev --group tests --extra standard
129115
- run: ls -la coverage
130-
- run: coverage combine coverage
131-
- run: coverage report
132-
- run: coverage html --title "Coverage for ${{ github.sha }}"
116+
- run: uv run coverage combine coverage
117+
- run: uv run coverage html --title "Coverage for ${{ github.sha }}"
133118
- name: Store coverage HTML
134-
uses: actions/upload-artifact@v5
119+
uses: actions/upload-artifact@v6
135120
with:
136121
name: coverage-html
137122
path: htmlcov
138123
include-hidden-files: true
124+
- run: uv run coverage report --fail-under=100
139125

140126
# https://github.com/marketplace/actions/alls-green#why
141127
check: # This job does nothing and is only used for the branch protection

.pre-commit-config.yaml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
3-
default_language_version:
4-
python: python3.10
53
repos:
64
- repo: https://github.com/pre-commit/pre-commit-hooks
75
rev: v6.0.0
@@ -13,13 +11,18 @@ repos:
1311
- --unsafe
1412
- id: end-of-file-fixer
1513
- id: trailing-whitespace
16-
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.14.6
14+
- repo: local
1815
hooks:
19-
- id: ruff
20-
args:
21-
- --fix
22-
- id: ruff-format
23-
ci:
24-
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
25-
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
16+
- id: local-ruff-check
17+
name: ruff check
18+
entry: uv run ruff check --force-exclude --fix --exit-non-zero-on-fix
19+
require_serial: true
20+
language: unsupported
21+
types: [python]
22+
23+
- id: local-ruff-format
24+
name: ruff format
25+
entry: uv run ruff format --force-exclude --exit-non-zero-on-format
26+
require_serial: true
27+
language: unsupported
28+
types: [python]

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.9

pdm_build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import Any, Dict
2+
from typing import Any
33

44
from pdm.backend.hooks import Context
55

@@ -9,12 +9,12 @@
99
def pdm_build_initialize(context: Context):
1010
metadata = context.config.metadata
1111
# Get custom config for the current package, from the env var
12-
config: Dict[str, Any] = context.config.data["tool"]["tiangolo"][
12+
config: dict[str, Any] = context.config.data["tool"]["tiangolo"][
1313
"_internal-slim-build"
1414
]["packages"].get(TIANGOLO_BUILD_PACKAGE)
1515
if not config:
1616
return
17-
project_config: Dict[str, Any] = config["project"]
17+
project_config: dict[str, Any] = config["project"]
1818
# Override main [project] configs with custom configs for this package
1919
for key, value in project_config.items():
2020
metadata[key] = value

0 commit comments

Comments
 (0)