Skip to content

Commit d9f3f81

Browse files
authored
Merge branch 'main' into ami/pydantic-jsonb
2 parents 1580ecc + 68fc5fa commit d9f3f81

33 files changed

+118
-314
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.11.8
17+
rev: v0.12.0
1818
hooks:
1919
- id: ruff
2020
args:

docs/release-notes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020
### Internal
2121

22+
*[pre-commit.ci] pre-commit autoupdate. PR [#1374](https://github.com/fastapi/sqlmodel/pull/1374) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
23+
* ⬆ Bump ruff from 0.11.13 to 0.12.0. PR [#1403](https://github.com/fastapi/sqlmodel/pull/1403) by [@dependabot[bot]](https://github.com/apps/dependabot).
24+
* ✅ Simplify tests for `tests/test_tutorial/test_code_structure/test_tutorial001.py`, one test file for multiple variants. PR [#1408](https://github.com/fastapi/sqlmodel/pull/1408) by [@tiangolo](https://github.com/tiangolo).
25+
* ✅ Simplify tests setup, one test file for multiple source variants. PR [#1407](https://github.com/fastapi/sqlmodel/pull/1407) by [@tiangolo](https://github.com/tiangolo).
26+
* ✅ Refactor tests to use autouse `clear_sqlmodel`. PR [#1406](https://github.com/fastapi/sqlmodel/pull/1406) by [@tiangolo](https://github.com/tiangolo).
27+
* ⬆ Bump mkdocs-material from 9.5.18 to 9.6.14. PR [#1378](https://github.com/fastapi/sqlmodel/pull/1378) by [@dependabot[bot]](https://github.com/apps/dependabot).
28+
* ⬆ Bump typer from 0.15.3 to 0.16.0. PR [#1393](https://github.com/fastapi/sqlmodel/pull/1393) by [@dependabot[bot]](https://github.com/apps/dependabot).
29+
* ⬆ Bump cairosvg from 2.7.1 to 2.8.2. PR [#1383](https://github.com/fastapi/sqlmodel/pull/1383) by [@dependabot[bot]](https://github.com/apps/dependabot).
30+
* ⬆ Bump ruff from 0.11.7 to 0.11.13. PR [#1397](https://github.com/fastapi/sqlmodel/pull/1397) by [@dependabot[bot]](https://github.com/apps/dependabot).
2231
* 🔧 Remove Google Analytics. PR [#1386](https://github.com/fastapi/sqlmodel/pull/1386) by [@tiangolo](https://github.com/tiangolo).
2332
* ⬆ Bump mkdocs-macros-plugin from 1.0.5 to 1.3.7. PR [#1354](https://github.com/fastapi/sqlmodel/pull/1354) by [@dependabot[bot]](https://github.com/apps/dependabot).
2433
* ⬆ Bump griffe-typingdoc from 0.2.5 to 0.2.8. PR [#1359](https://github.com/fastapi/sqlmodel/pull/1359) by [@dependabot[bot]](https://github.com/apps/dependabot).

requirements-docs.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-e .
22
-r requirements-docs-tests.txt
3-
mkdocs-material==9.5.18
3+
mkdocs-material==9.6.14
44
mdx-include >=1.4.1,<2.0.0
55
mkdocs-redirects>=1.2.1,<1.3.0
66
pyyaml >=5.3.1,<7.0.0
@@ -9,10 +9,10 @@ pyyaml >=5.3.1,<7.0.0
99
# For image processing by Material for MkDocs
1010
pillow==11.2.1
1111
# For image processing by Material for MkDocs
12-
cairosvg==2.7.1
12+
cairosvg==2.8.2
1313
# mkdocstrings[python]==0.25.1
1414
griffe-typingdoc==0.2.8
1515
# For griffe, it formats with black
16-
typer == 0.15.3
16+
typer == 0.16.0
1717
mkdocs-macros-plugin==1.3.7
1818
markdown-include-variants==0.0.4

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pytest >=7.0.1,<9.0.0
44
coverage[toml] >=6.2,<8.0
55
mypy ==1.4.1
6-
ruff ==0.11.7
6+
ruff ==0.12.0
77
# For FastAPI tests
88
fastapi >=0.103.2
99
httpx ==0.28.1

tests/conftest.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import shutil
22
import subprocess
33
import sys
4+
from dataclasses import dataclass, field
45
from pathlib import Path
5-
from typing import Any, Callable, Dict, List, Union
6+
from typing import Any, Callable, Dict, Generator, List, Union
7+
from unittest.mock import patch
68

79
import pytest
810
from pydantic import BaseModel
@@ -14,8 +16,8 @@
1416
docs_src_path = top_level_path / "docs_src"
1517

1618

17-
@pytest.fixture()
18-
def clear_sqlmodel():
19+
@pytest.fixture(autouse=True)
20+
def clear_sqlmodel() -> Any:
1921
# Clear the tables in the metadata for the default base model
2022
SQLModel.metadata.clear()
2123
# Clear the Models associated with the registry, to avoid warnings
@@ -26,7 +28,7 @@ def clear_sqlmodel():
2628

2729

2830
@pytest.fixture()
29-
def cov_tmp_path(tmp_path: Path):
31+
def cov_tmp_path(tmp_path: Path) -> Generator[Path, None, None]:
3032
yield tmp_path
3133
for coverage_path in tmp_path.glob(".coverage*"):
3234
coverage_destiny_path = top_level_path / coverage_path.name
@@ -53,8 +55,8 @@ def coverage_run(*, module: str, cwd: Union[str, Path]) -> subprocess.CompletedP
5355
def get_testing_print_function(
5456
calls: List[List[Union[str, Dict[str, Any]]]],
5557
) -> Callable[..., Any]:
56-
def new_print(*args):
57-
data = []
58+
def new_print(*args: Any) -> None:
59+
data: List[Any] = []
5860
for arg in args:
5961
if isinstance(arg, BaseModel):
6062
data.append(arg.model_dump())
@@ -71,6 +73,19 @@ def new_print(*args):
7173
return new_print
7274

7375

76+
@dataclass
77+
class PrintMock:
78+
calls: List[Any] = field(default_factory=list)
79+
80+
81+
@pytest.fixture(name="print_mock")
82+
def print_mock_fixture() -> Generator[PrintMock, None, None]:
83+
print_mock = PrintMock()
84+
new_print = get_testing_print_function(print_mock.calls)
85+
with patch("builtins.print", new=new_print):
86+
yield print_mock
87+
88+
7489
needs_pydanticv2 = pytest.mark.skipif(not IS_PYDANTIC_V2, reason="requires Pydantic v2")
7590
needs_pydanticv1 = pytest.mark.skipif(IS_PYDANTIC_V2, reason="requires Pydantic v1")
7691

tests/test_advanced/test_decimal/test_tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
]
3131

3232

33-
def test_tutorial(clear_sqlmodel):
33+
def test_tutorial():
3434
from docs_src.advanced.decimal import tutorial001 as mod
3535

3636
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_decimal/test_tutorial001_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
@needs_py310
34-
def test_tutorial(clear_sqlmodel):
34+
def test_tutorial():
3535
from docs_src.advanced.decimal import tutorial001_py310 as mod
3636

3737
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ...conftest import get_testing_print_function
77

88

9-
def test_tutorial(clear_sqlmodel) -> None:
9+
def test_tutorial() -> None:
1010
from docs_src.advanced.uuid import tutorial001 as mod
1111

1212
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial001_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@needs_py310
10-
def test_tutorial(clear_sqlmodel) -> None:
10+
def test_tutorial() -> None:
1111
from docs_src.advanced.uuid import tutorial001_py310 as mod
1212

1313
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial002.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ...conftest import get_testing_print_function
77

88

9-
def test_tutorial(clear_sqlmodel) -> None:
9+
def test_tutorial() -> None:
1010
from docs_src.advanced.uuid import tutorial002 as mod
1111

1212
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial002_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@needs_py310
10-
def test_tutorial(clear_sqlmodel) -> None:
10+
def test_tutorial() -> None:
1111
from docs_src.advanced.uuid import tutorial002_py310 as mod
1212

1313
mod.sqlite_url = "sqlite://"

tests/test_tutorial/test_automatic_id_none_refresh/test_tutorial001_py310_tutorial002_py310.py

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)