Skip to content

Commit a1f43ca

Browse files
committed
drop python 3.8
1 parent 2cd7474 commit a1f43ca

20 files changed

+939
-140
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,24 @@ jobs:
1919
strategy:
2020
matrix:
2121
# https://github.com/actions/python-versions/blob/main/versions-manifest.json
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
django-version:
2424
- "Django>=4.2,<5.0"
2525
- "Django>=5.0,<5.1"
2626
- "Django>=5.1,<5.2"
27+
- "Django==5.2a1"
2728
# - "https://github.com/django/django/archive/main.tar.gz"
2829
include:
2930
- drf: djangorestframework
3031
python-version: "3.12"
3132
django-version: "Django<5.2,>=5.0" # must be different from django-version
3233
exclude:
33-
- django-version: "Django>=5.0,<5.1"
34-
python-version: 3.8
3534
- django-version: "Django>=5.0,<5.1"
3635
python-version: 3.9
37-
- django-version: "Django>=5.1,<5.2"
38-
python-version: 3.8
3936
- django-version: "Django>=5.1,<5.2"
4037
python-version: 3.9
38+
- django-version: "Django==5.2a1"
39+
python-version: 3.9
4140
# - django-version: "https://github.com/django/django/archive/main.tar.gz"
4241
# python-version: 3.8
4342
# - django-version: "https://github.com/django/django/archive/main.tar.gz"
@@ -46,16 +45,19 @@ jobs:
4645
steps:
4746
- uses: actions/checkout@v4
4847
- uses: actions/setup-python@v5
49-
if: "!endsWith(matrix.python-version, '-dev')"
5048
with:
5149
python-version: ${{ matrix.python-version }}
52-
cache: "pip"
53-
cache-dependency-path: "pyproject.toml"
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v5
52+
- name: Patch pyproject.toml
53+
if: "matrix.python-version != '3.9'"
54+
run: |
55+
sed -i 's/requires-python = ">=3.9"/requires-python = ">=3.10"/' pyproject.toml
5456
- name: Install deps
5557
run: |
56-
python -m pip install -e .[test]
57-
python -m pip install "${{ matrix.django-version }}" ${{ matrix.drf }}
58-
- run: pytest
58+
uv add --group test "${{ matrix.django-version }}" ${{ matrix.drf }}
59+
uv sync --no-dev --group test
60+
- run: uv run pytest
5961

6062
lint:
6163
runs-on: ubuntu-latest
@@ -67,14 +69,14 @@ jobs:
6769
- uses: actions/setup-python@v5
6870
with:
6971
python-version: "3.12"
70-
cache: "pip"
71-
cache-dependency-path: "pyproject.toml"
72+
- name: Install uv
73+
uses: astral-sh/setup-uv@v5
7274
- uses: actions/cache@v4
7375
with:
7476
path: ~/.cache/pre-commit
7577
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
76-
- run: python -m pip install -e .[dev]
77-
- run: pre-commit run --show-diff-on-failure --color=always --all-files
78+
- run: uv sync
79+
- run: uv run pre-commit run --show-diff-on-failure --color=always --all-files
7880

7981
package:
8082
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
### Unreleased
44

5+
- drop python 3.8 support
6+
- add django 5.2 to test matrix
7+
58
### 0.16.1
69

710
- fix `field-choices-constraint`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ EXTRA_CHECKS = {
126126

127127
## Development
128128

129-
Install dev deps in virtualenv `pip install -e .[dev,test]`.
129+
Install dev deps in virtualenv `uv sync --group test`.
130130

131131
## Credits
132132

conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def handler(self, handler):
3535
def run(self):
3636
self._registry.enabled_checks = {}
3737
handlers = self._registry.bind()
38-
assert (
39-
self._registry.is_healthy
40-
), f"Settings has errors: {self._registry._config.errors.as_text()}"
38+
assert self._registry.is_healthy, (
39+
f"Settings has errors: {self._registry._config.errors.as_text()}"
40+
)
4141
return list(handlers[self.TEST_TAG]())
4242

4343
def models(self, *models):

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
let
1818
pkgs = import nixpkgs { inherit system; };
1919
app-test = pkgs.writeShellScriptBin "app.test" ''pytest $@'';
20-
app-install = pkgs.writeShellScriptBin "app.install" ''uv pip install -e .[dev,test] && pre-commit install'';
20+
app-install = pkgs.writeShellScriptBin "app.install" ''uv sync && pre-commit install'';
2121
app-typecheck = pkgs.writeShellScriptBin "app.typecheck" ''mypy src/extra_checks tests'';
2222
app-lint = pkgs.writeShellScriptBin "app.lint" ''pre-commit run -a'';
2323
in
2424
{
2525
devShells.default = pkgs.mkShell {
2626
packages = [
27-
pkgs.python312
27+
pkgs.python313
2828
pkgs.pre-commit
29+
pkgs.uv
2930
];
3031
buildInputs = [
3132
app-test

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description = "Collection of useful checks for Django Checks Framework"
99
readme = "README.md"
1010
license = "MIT"
11-
requires-python = ">=3.8"
11+
requires-python = ">=3.9"
1212
authors = [
1313
{ name = "Konstantin Alekseev", email = "[email protected]" },
1414
]
@@ -23,20 +23,20 @@ classifiers = [
2323
"Framework :: Django :: 4.2",
2424
"Framework :: Django :: 5.0",
2525
"Framework :: Django :: 5.1",
26+
"Framework :: Django :: 5.2",
2627
"Intended Audience :: Developers",
2728
"License :: OSI Approved :: MIT License",
2829
"Operating System :: OS Independent",
2930
"Programming Language :: Python",
3031
"Programming Language :: Python :: 3",
31-
"Programming Language :: Python :: 3.8",
3232
"Programming Language :: Python :: 3.9",
3333
"Programming Language :: Python :: 3.10",
3434
"Programming Language :: Python :: 3.11",
3535
"Programming Language :: Python :: 3.12",
3636
"Programming Language :: Python :: 3.13",
3737
]
3838

39-
[project.optional-dependencies]
39+
[dependency-groups]
4040
dev = [
4141
"Django",
4242
"django-stubs",
@@ -46,6 +46,7 @@ dev = [
4646
"pdbpp",
4747
"pre-commit",
4848
"ruff",
49+
{include-group = "test"},
4950
]
5051
test = [
5152
"pytest",
@@ -67,7 +68,7 @@ packages = ["src/extra_checks"]
6768

6869
[tool.ruff]
6970
src = ["src"]
70-
target-version = "py38"
71+
target-version = "py39"
7172
[tool.ruff.lint]
7273
select = [
7374
'B',

src/extra_checks/ast/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Container, Type
1+
from collections.abc import Container
22

33
from django.db import models
44

@@ -14,7 +14,7 @@
1414

1515

1616
def get_model_ast(
17-
model_cls: Type[models.Model],
17+
model_cls: type[models.Model],
1818
meta_checks: Container[CheckId],
1919
) -> ModelASTDisableCommentProtocol:
2020
return ModelAST(model_cls, meta_checks)

src/extra_checks/ast/ast.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import ast
2+
from collections.abc import Container, Iterable, Iterator
23
from functools import partial
34
from typing import (
45
TYPE_CHECKING,
56
Callable,
6-
Container,
7-
Dict,
8-
Iterable,
9-
Iterator,
10-
List,
117
Optional,
12-
Tuple,
13-
Type,
148
Union,
159
cast,
1610
)
@@ -36,10 +30,10 @@
3630

3731

3832
class ModelAST(DisableCommentProtocol, ModelASTProtocol):
39-
def __init__(self, model_cls: Type[models.Model], meta_checks: Container[CheckId]):
33+
def __init__(self, model_cls: type[models.Model], meta_checks: Container[CheckId]):
4034
self.model_cls = model_cls
4135
self.meta_checks = meta_checks
42-
self._assignment_nodes: List[ast.Assign] = []
36+
self._assignment_nodes: list[ast.Assign] = []
4337
self._meta: Optional[ast.ClassDef] = None
4438

4539
@cached_property
@@ -73,8 +67,8 @@ def _meta_node(self) -> Optional[ast.ClassDef]:
7367
return self._meta
7468

7569
@cached_property
76-
def _meta_vars(self) -> Dict[str, ast.Assign]:
77-
data: Dict[str, ast.Assign] = {}
70+
def _meta_vars(self) -> dict[str, ast.Assign]:
71+
data: dict[str, ast.Assign] = {}
7872
if not self._meta_node:
7973
return data
8074
for node in ast.iter_child_nodes(self._meta_node):
@@ -83,7 +77,7 @@ def _meta_vars(self) -> Dict[str, ast.Assign]:
8377
return data
8478

8579
@cached_property
86-
def _assignments(self) -> Dict[str, ast.Assign]:
80+
def _assignments(self) -> dict[str, ast.Assign]:
8781
self._parse()
8882
result = {}
8983
for node in self._assignment_nodes:
@@ -92,7 +86,7 @@ def _assignments(self) -> Dict[str, ast.Assign]:
9286
return result
9387

9488
@cached_property
95-
def field_nodes(self) -> Iterable[Tuple[models.fields.Field, "FieldAST"]]:
89+
def field_nodes(self) -> Iterable[tuple[models.fields.Field, "FieldAST"]]:
9690
for field in self.model_cls._meta.get_fields(include_parents=False):
9791
if isinstance(field, models.Field):
9892
yield (
@@ -155,11 +149,11 @@ def __init__(
155149
self._source_provider = source_provider
156150

157151
@cached_property
158-
def _args(self) -> List[ast.expr]:
152+
def _args(self) -> list[ast.expr]:
159153
return self._node.value.args # type: ignore
160154

161155
@cached_property
162-
def _kwargs(self) -> Dict[str, ast.keyword]:
156+
def _kwargs(self) -> dict[str, ast.keyword]:
163157
return {kw.arg: kw for kw in self._node.value.keywords if kw.arg} # type: ignore
164158

165159
def get_arg(self, name: str) -> Optional[ArgASTProtocol]:

src/extra_checks/ast/protocols.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Iterable, Optional, Protocol, Tuple
1+
from collections.abc import Iterable
2+
from typing import Any, Optional, Protocol
23

34
from django.db import models
45

@@ -21,7 +22,7 @@ class ModelASTProtocol(Protocol):
2122
@property
2223
def field_nodes(
2324
self,
24-
) -> Iterable[Tuple[models.fields.Field, "FieldASTDisableCommentProtocol"]]: ...
25+
) -> Iterable[tuple[models.fields.Field, "FieldASTDisableCommentProtocol"]]: ...
2526

2627
def has_meta_var(self, name: str) -> bool: ...
2728

0 commit comments

Comments
 (0)