Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uv to manage conflicting django versions for tests #65

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
{ name = "Stephen Moore", email = "stephen@delfick.com" },
]
dependencies = [
"django==4.2.9",
"django>=4.2.16",
"psycopg2-binary==2.9.9",
]

Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ authors = [
]
requires-python = ">=3.10"

[tool.uv]
dev-dependencies = [
"tools",
"djangoexample",
"proper_plugin",
"extended_mypy_django_plugin_test_driver",
]

[tool.hatch.metadata]
allow-direct-references = true

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

[dependency-groups]
dev = [
"tools",
"djangoexample",
"proper_plugin",
"extended_mypy_django_plugin_test_driver",
]

[tool.ruff]
target-version = "py310"
line-length = 99
Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
import importlib

import pytest

pytest_plugins = ["pytest_typing_runner", "extended_mypy_django_plugin_test_driver.plugin"]


def pytest_report_header(config: pytest.Config) -> list[str] | None:
return [f"Django: {importlib.metadata.version('django')}"]
17 changes: 16 additions & 1 deletion tools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies = [
"click>=8.1.7",
"ruff==0.5.0",
"remote-pdb==2.1.0",
"django-stubs==5.1.1",
"mypy==1.13.0"
]

Expand All @@ -17,3 +16,19 @@ docs = [
"sphinx-toolbox==3.8.0",
"sphinx==8.0.2",
]
old-django = [
"django-stubs==5.1.1",
"django==4.2.16"
]
new-django = [
"django-stubs==5.1.1",
"django==5.1.3"
]

[tool.uv]
conflicts = [
[
{ extra = "old-django" },
{ extra = "new-django" },
],
]
2 changes: 1 addition & 1 deletion tools/requirements.uv.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
uv==0.5.4
uv==0.5.8
32 changes: 16 additions & 16 deletions tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@
here = pathlib.Path(__file__).parent


def run_with_mypy(*args: str, old: bool) -> None:
def run(*args: str, old: bool) -> None:
if old:
withs = [
"--with",
"django==4.2.16",
]
withs = ["--package", "tools", "--extra", "old-django"]
else:
withs = [
"--with",
"django==5.1.2",
]
withs = ["--package", "tools", "--extra", "new-django"]

try:
subprocess.run(["/bin/bash", str(here / "uv"), "run", *withs, *args], check=True)
Expand Down Expand Up @@ -55,7 +49,7 @@ def docs(args: list[str], old: bool) -> None:
(build_path / "html").mkdir(exist_ok=True, parents=True)
(build_path / "doctrees").mkdir(exist_ok=True, parents=True)

run_with_mypy(
run(
"--package",
"tools",
"--extra",
Expand Down Expand Up @@ -131,13 +125,19 @@ def types(args: list[str], old: bool) -> None:
os.chdir(example_root)
locations = [str(path) for path in paths]

run_with_mypy(
"python", "-m", "mypy", *locations, *args, "--enable-incomplete-feature=Unpack", old=old
)
run("python", "-m", "mypy", *locations, *args, "--enable-incomplete-feature=Unpack", old=old)

if not specified:
os.chdir(here.parent / "example")
run_with_mypy("python", "-m", "mypy", ".", *args, old=old)
run(
"python",
"-m",
"mypy",
str(here.parent / "example"),
"--config-file",
str(here.parent / "example" / "mypy.ini"),
*args,
old=old,
)


@cli.command(context_settings=dict(ignore_unknown_options=True))
Expand All @@ -147,7 +147,7 @@ def tests(args: list[str], old: bool) -> None:
"""
Run pytest
"""
run_with_mypy("python", "-m", "pytest", *args, old=old)
run("python", "-m", "pytest", *args, old=old)


if __name__ == "__main__":
Expand Down
Loading
Loading