8000 Merge branch 'main' into codeflash/optimize-GenerateJsonSchema.litera… · pydantic/pydantic@c8e6856 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8e6856

Browse files
Merge branch 'main' into codeflash/optimize-GenerateJsonSchema.literal_schema-2024-12-03T01.15.46
2 parents dc753bd + 6a5b640 commit c8e6856

File tree

218 files changed

+6535
-6207
lines changed

Some content is hidden

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

218 files changed

+6535
-6207
lines changed

.github/actions/people/people.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
[FastAPI people script](https://github.com/tiangolo/fastapi/blob/master/.github/actions/people/app/main.py).
55
"""
66

7+
# TODO: add docstrings to classes and functions (good first issue)
8+
# ruff: noqa: D101
9+
# ruff: noqa: D103
10+
711
import logging
812
import subprocess
913
import sys
1014
from collections import Counter
15+
from collections.abc import Container
1116
from datetime import datetime, timedelta, timezone
1217
from pathlib import Path
13-
from typing import Any, Container, Dict, List, Set, Union
18+
from typing import Any, Union
1419

1520
import requests
1621
import yaml
@@ -23,7 +28,7 @@
2328

2429
discussions_query = """
2530
query Q($after: String) {
26-
repository(name: "pydantic", owner: "samuelcolvin") {
31+
repository(name: "pydantic", owner: "pydantic") {
2732
discussions(first: 100, after: $after) {
2833
edges {
2934
cursor
@@ -161,19 +166,19 @@ class CommentsNode(BaseModel):
161166

162167

163168
class Replies(BaseModel):
164-
nodes: List[CommentsNode]
169+
nodes: list[CommentsNode]
165170

166171

167172
class DiscussionsCommentsNode(CommentsNode):
168173
replies: Replies
169174

170175

171176
class Comments(BaseModel):
172-
nodes: List[CommentsNode]
BD94
177+
nodes: list[CommentsNode]
173178

174179

175180
class DiscussionsComments(BaseModel):
176-
nodes: List[DiscussionsCommentsNode]
181+
nodes: list[DiscussionsCommentsNode]
177182

178183

179184
class IssuesNode(BaseModel):
@@ -204,11 +209,11 @@ class DiscussionsEdge(BaseModel):
204209

205210

206211
class Issues(BaseModel):
207-
edges: List[IssuesEdge]
212+
edges: list[IssuesEdge]
208213

209214

210215
class Discussions(BaseModel):
211-
edges: List[DiscussionsEdge]
216+
edges: list[DiscussionsEdge]
212217

213218

214219
class IssuesRepository(BaseModel):
@@ -243,7 +248,7 @@ class LabelNode(BaseModel):
243248

244249

245250
class Labels(BaseModel):
246-
nodes: List[LabelNode]
251+
nodes: list[LabelNode]
247252

248253

249254
class ReviewNode(BaseModel):
@@ -252,7 +257,7 @@ class ReviewNode(BaseModel):
252257

253258

254259
class Reviews(BaseModel):
255-
nodes: List[ReviewNode]
260+
nodes: list[ReviewNode]
256261

257262

258263
class PullRequestNode(BaseModel):
@@ -272,7 +277,7 @@ class PullRequestEdge(BaseModel):
272277

273278

274279
class PullRequests(BaseModel):
275-
edges: List[PullRequestEdge]
280+
edges: list[PullRequestEdge]
276281

277282

278283
class PRsRepository(BaseModel):
@@ -298,7 +303,7 @@ def get_graphql_response(
298303
settings: Settings,
299304
query: str,
300305
after: Union[str, None] = None,
301-
) -> Dict[str, Any]:
306+
) -> dict[str, Any]:
302307
headers = {'Authorization': f'token {settings.input_token.get_secret_value()}'}
303308
variables = {'after': after}
304309
response = requests.post(
@@ -347,7 +352,7 @@ def get_graphql_pr_edges(*, settings: Settings, after: Union[str, None] = None):
347352

348353

349354
def get_issues_experts(settings: Settings):
350-
issue_nodes: List[IssuesNode] = []
355+
issue_nodes: list[IssuesNode] = []
351356
issue_edges = get_graphql_issue_edges(settings=settings)
352357

353358
while issue_edges:
@@ -358,7 +363,7 @@ def get_issues_experts(settings: Settings):
358363

359364
commentors = Counter()
360365
last_month_commentors = Counter()
361-
authors: Dict[str, Author] = {}
366+
authors: dict[str, Author] = {}
362367

363368
now = datetime.now(tz=timezone.utc)
364369
one_month_ago = now - timedelta(days=30)
@@ -383,7 +388,7 @@ def get_issues_experts(settings: Settings):
383388

384389

385390
def get_discussions_experts(settings: Settings):
386-
discussion_nodes: List[DiscussionsNode] = []
391+
discussion_nodes: list[DiscussionsNode] = []
387392
discussion_edges = get_graphql_question_discussion_edges(settings=settings)
388393

389394
while discussion_edges:
@@ -394,7 +399,7 @@ def get_discussions_experts(settings: Settings):
394399

395400
commentors = Counter()
396401
last_month_commentors = Counter()
397-
authors: Dict[str, Author] = {}
402+
authors: dict[str, Author] = {}
398403

399404
now = datetime.now(tz=timezone.utc)
400405
one_month_ago = now - timedelta(days=30)
@@ -446,7 +451,7 @@ def get_experts(settings: Settings):
446451

447452

448453
def get_contributors(settings: Settings):
449-
pr_nodes: List[PullRequestNode] = []
454+
pr_nodes: list[PullRequestNode] = []
450455
pr_edges = get_graphql_pr_edges(settings=settings)
451456

452457
while pr_edges:
@@ -458,15 +463,15 @@ def get_contributors(settings: Settings):
458463
contributors = Counter()
459464
commentors = Counter()
460465
reviewers = Counter()
461-
authors: Dict[str, Author] = {}
466+
authors: dict[str, Author] = {}
462467

463468
for pr in pr_nodes:
464469
author_name = None
465470
if pr.author:
466471
authors[pr.author.login] = pr.author
467472
author_name = pr.author.login
468-
pr_commentors: Set[str] = set()
469-
pr_reviewers: Set[str] = set()
473+
pr_commentors: set[str] = set()
474+
pr_reviewers: set[str] = set()
470475
for comment in pr.comments.nodes:
471476
if comment.author:
472477
authors[comment.author.login] = comment.author
@@ -490,7 +495,7 @@ def get_top_users(
490495
*,
491496
counter: Counter,
492497
min_count: int,
493-
authors: Dict[str, Author],
498+
authors: dict[str, Author],
494499
skip_users: Container[str],
495500
):
496501
users = []
@@ -528,6 +533,7 @@ def get_top_users(
528533
'davidhewitt',
529534
'sydney-runkle',
530535
'alexmojaki',
536+
'Viicos',
531537
}
532538
bot_names = {'codecov', 'github-actions', 'pre-commit-ci', 'dependabot'}
533539
maintainers = []

.github/workflows/ci.yml

Lines changed: 31 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
22+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
2323
steps:
2424
- uses: actions/checkout@v4
2525

26-
- uses: astral-sh/setup-uv@v3
26+
- uses: astral-sh/setup-uv@v5
2727
with:
28-
enable-cache: true
28+
python-version: ${{ matrix.python-version }}
2929

3030
- name: Install dependencies
31-
run: uv sync --python ${{ matrix.python-version }} --group linting --all-extras
32-
31+
# Installing pip is required for the pre-commit action:
32+
run: |
33+
uv sync --group linting --all-extras
34+
uv pip install pip
3335
- uses: pre-commit/action@v3.0.1
3436
with:
3537
extra_args: --all-files --verbose
@@ -41,15 +43,15 @@ jobs:
4143
steps:
4244
- uses: actions/checkout@v4
4345

44-
- uses: astral-sh/setup-uv@v3
46+
- uses: astral-sh/setup-uv@v5
4547
with:
46-
enable-cache: true
48+
python-version: '3.12'
4749

4850
- name: Install dependencies
4951
# Unlike the docs build, we don't use mkdocs_material-insiders
5052
# Because the secret for accessing the library is not accessible from forks, but we still want to run
5153
# this job on public CI runs.
52-
run: uv sync --python 3.12 --group docs
54+
run: uv sync --group docs
5355

5456
- run: uv run python -c 'import docs.plugins.main'
5557

@@ -71,12 +73,12 @@ jobs:
7173
steps:
7274
- uses: actions/checkout@v4
7375

74-
- uses: astral-sh/setup-uv@v3
76+
- uses: astral-sh/setup-uv@v5
7577
with:
76-
enable-cache: true
78+
python-version: '3.12'
7779

7880
- name: install deps
79-
run: uv sync --python 3.12 --group testing-extra
81+
run: uv sync --group testing-extra
8082

8183
- name: Run tests
8284
run: uv run pytest --ignore=tests/mypy/ --ignore=tests/test_docs.py --memray
@@ -87,7 +89,7 @@ jobs:
8789
fail-fast: false
8890
matrix:
8991
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
90-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
92+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
9193
include:
9294
# no pydantic-core binaries for pypy on windows, so tests take absolute ages
9395
# macos tests with pypy take ages (>10mins) since pypy is very slow
@@ -97,7 +99,7 @@ jobs:
9799
- os: ubuntu-latest
98100
python-version: 'pypy3.10'
99101
exclude:
100-
# Python 3.8 and 3.9 are not available on macOS 14
102+
# Python 3.9 is not available on macOS 14
101103
- os: macos-13
102104
python-version: '3.10'
103105
- os: macos-13
@@ -106,25 +108,22 @@ jobs:
106108
python-version: '3.12'
107109
- os: macos-latest
108110
python-version: '3.13'
109-
- os: macos-latest
110-
python-version: '3.8'
111111
- os: macos-latest
112112
python-version: '3.9'
113113

114114
env:
115115
OS: ${{ matrix.os }}
116116
DEPS: yes
117-
UV_PYTHON: ${{ matrix.python-version }}
118117
UV_PYTHON_PREFERENCE: only-managed
119118

120119
runs-on: ${{ matrix.os }}
121120

122121
steps:
123122
- uses: actions/checkout@v4
124123

125-
- uses: astral-sh/setup-uv@v3
124+
- uses: astral-sh/setup-uv@v5
126125
with:
127-
enable-cache: true
126+
python-version: ${{ matrix.python-version }}
128127

129128
- name: Install dependencies
130129
run: uv sync --extra timezone
@@ -157,32 +156,18 @@ jobs:
157156
path: coverage
158157
include-hidden-files: true
159158

160-
test-fastapi:
161-
# If some tests start failing due to out-of-date schemas/validation errors/etc.,
162-
# update the `tests/test_fastapi.sh` script to exclude tests that have known-acceptable failures.
163-
name: Test FastAPI
164-
runs-on: ubuntu-latest
165-
steps:
166-
- uses: actions/checkout@v4
167-
168-
- name: set up python
169-
uses: actions/setup-python@v5
170-
with:
171-
python-version: '3.12'
172-
173-
- name: Run tests
174-
run: make test-fastapi
175-
176159
test-plugin:
177160
name: Test Pydantic plugin
178161
runs-on: ubuntu-latest
179162
steps:
180163
- uses: actions/checkout@v4
181164

182-
- uses: astral-sh/setup-uv@v3
165+
- uses: astral-sh/setup-uv@v5
166+
with:
167+
python-version: '3.12'
183168

184169
- name: Install dependencies
185-
run: uv sync --python 3.12
170+
run: uv sync
186171

187172
- name: Install example plugin
188173
run: uv pip install ./tests/plugin
@@ -201,8 +186,6 @@ jobs:
201186
mypy-version: ['1.10.1', '1.11.2']
202187
python-version: ['3.12']
203188
include:
204-
- mypy-version: '1.12.0'
205-
python-version: '3.8'
206189
- mypy-version: '1.12.0'
207190
python-version: '3.9'
208191
- mypy-version: '1.12.0'
@@ -217,12 +200,12 @@ jobs:
217200
steps:
218201
- uses: actions/checkout@v4
219202

220-
- uses: astral-sh/setup-uv@v3
203+
- uses: astral-sh/setup-uv@v5
221204
with:
222-
enable-cache: true
205+
python-version: ${{ matrix.python-version }}
223206

224207
- name: Install dependencies
225-
run: uv sync --python ${{ matrix.python-version }} --group typechecking --all-extras
208+
run: uv sync --group typechecking --all-extras
226209

227210
- name: Install mypy
228211
if: steps.cache.outputs.cache-hit != 'true'
@@ -249,12 +232,12 @@ jobs:
249232
steps:
250233
- uses: actions/checkout@v4
251234

252-
- uses: astral-sh/setup-uv@v3
235+
- uses: astral-sh/setup-uv@v5
253236
with:
254-
enable-cache: true
237+
python-version: '3.12'
255238

256239
- name: Install dependencies
257-
run: uv sync --python 3.12 --group typechecking
240+
run: uv sync --group typechecking
258241

259242
- name: Run typechecking integration tests (Pyright)
260243
run: make test-typechecking-pyright
@@ -335,16 +318,16 @@ jobs:
335318
strategy:
336319
fail-fast: false
337320
matrix:
338-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
321+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
339322
steps:
340323
- uses: actions/checkout@v4
341324

342-
- uses: astral-sh/setup-uv@v3
325+
- uses: astral-sh/setup-uv@v5
343326
with:
344-
enable-cache: true
327+
python-version: ${{ matrix.python-version }}
345328

346329
- name: Install dependencies
347-
run: uv sync --python ${{ matrix.python-version }}
330+
run: uv sync
348331

349332
- name: Install typing-extensions
350333
run: uv pip install 'typing-extensions @ git+https://github.com/python/typing_extensions.git'
@@ -365,7 +348,6 @@ jobs:
365348
- test
366349
- test-memray
367350
- test-mypy
368-
- test-fastapi
369351
- test-plugin
370352

371353
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)
0