Skip to content

Commit 7710269

Browse files
committed
Use uv to manage conflicting django versions for tests
1 parent 47c23a8 commit 7710269

File tree

5 files changed

+459
-318
lines changed

5 files changed

+459
-318
lines changed

pyproject.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ authors = [
1313
]
1414
requires-python = ">=3.10"
1515

16-
[tool.uv]
17-
dev-dependencies = [
18-
"tools",
19-
"djangoexample",
20-
"proper_plugin",
21-
"extended_mypy_django_plugin_test_driver",
22-
]
23-
2416
[tool.hatch.metadata]
2517
allow-direct-references = true
2618

@@ -41,6 +33,14 @@ extended_mypy_django_plugin_test_driver = { workspace = true }
4133
[tool.uv.workspace]
4234
members = ["tools", "example", "scripts/test_helpers", "scripts/proper_plugin"]
4335

36+
[dependency-groups]
37+
dev = [
38+
"tools",
39+
"djangoexample",
40+
"proper_plugin",
41+
"extended_mypy_django_plugin_test_driver",
42+
]
43+
4444
[tool.ruff]
4545
target-version = "py310"
4646
line-length = 99

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1+
import importlib
2+
3+
import pytest
4+
15
pytest_plugins = ["pytest_typing_runner", "extended_mypy_django_plugin_test_driver.plugin"]
6+
7+
8+
def pytest_report_header(config: pytest.Config) -> list[str] | None:
9+
return [f"Django: {importlib.metadata.version('django')}"]

tools/pyproject.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ dependencies = [
66
"click>=8.1.7",
77
"ruff==0.5.0",
88
"remote-pdb==2.1.0",
9-
"django-stubs==5.1.1",
109
"mypy==1.13.0"
1110
]
1211

@@ -17,3 +16,19 @@ docs = [
1716
"sphinx-toolbox==3.8.0",
1817
"sphinx==8.0.2",
1918
]
19+
old-django = [
20+
"django-stubs==5.1.1",
21+
"django==4.2.16"
22+
]
23+
new-django = [
24+
"django-stubs==5.1.1",
25+
"django==5.1.3"
26+
]
27+
28+
[tool.uv]
29+
conflicts = [
30+
[
31+
{ extra = "old-django" },
32+
{ extra = "new-django" },
33+
],
34+
]

tools/run.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@
1111

1212
def run(*args: str, old: bool) -> None:
1313
if old:
14-
withs = [
15-
"--with",
16-
"django==4.2.16",
17-
]
14+
withs = ["--package", "tools", "--extra", "old-django"]
1815
else:
19-
withs = [
20-
"--with",
21-
"django==5.1.3",
22-
]
16+
withs = ["--package", "tools", "--extra", "new-django"]
2317

2418
try:
2519
subprocess.run(["/bin/bash", str(here / "uv"), "run", *withs, *args], check=True)
@@ -134,8 +128,16 @@ def types(args: list[str], old: bool) -> None:
134128
run("python", "-m", "mypy", *locations, *args, "--enable-incomplete-feature=Unpack", old=old)
135129

136130
if not specified:
137-
os.chdir(here.parent / "example")
138-
run("python", "-m", "mypy", ".", *args, old=old)
131+
run(
132+
"python",
133+
"-m",
134+
"mypy",
135+
str(here.parent / "example"),
136+
"--config-file",
137+
str(here.parent / "example" / "mypy.ini"),
138+
*args,
139+
old=old,
140+
)
139141

140142

141143
@cli.command(context_settings=dict(ignore_unknown_options=True))

0 commit comments

Comments
 (0)