Skip to content

Commit

Permalink
Use uv dependency groups to manage django
Browse files Browse the repository at this point in the history
  • Loading branch information
delfick committed Dec 1, 2024
1 parent a4b1622 commit 9885382
Show file tree
Hide file tree
Showing 6 changed files with 450 additions and 303 deletions.
1 change: 0 additions & 1 deletion example/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ authors = [
{ name = "Stephen Moore", email = "stephen@delfick.com" },
]
dependencies = [
"django>=4.2.16",
"psycopg2-binary==2.9.9",
]

Expand Down
32 changes: 24 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,30 @@ 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",
]
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 = [
[
{ group = "old-django" },
{ group = "new-django" },
],
]

[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')}"]
1 change: 0 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 Down
22 changes: 12 additions & 10 deletions tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@

def run(*args: str, old: bool) -> None:
if old:
withs = [
"--with",
"django==4.2.16",
]
withs = ["--group", "old-django"]
else:
withs = [
"--with",
"django==5.1.3",
]
withs = ["--group", "new-django"]

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

if not specified:
os.chdir(here.parent / "example")
run("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 Down
Loading

0 comments on commit 9885382

Please sign in to comment.