Skip to content

Commit cdfa454

Browse files
authored
min python 3.10 changes
1 parent 2217b64 commit cdfa454

File tree

3 files changed

+14
-183
lines changed

3 files changed

+14
-183
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +0,0 @@
1-
name: main
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
tags:
8-
- "*"
9-
pull_request:
10-
11-
concurrency:
12-
group: ${{ github.workflow }}-${{ github.ref }}
13-
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
14-
15-
env:
16-
PYTEST_ADDOPTS: "--color=yes"
17-
18-
# Set permissions at the job level.
19-
permissions: {}
20-
21-
jobs:
22-
test:
23-
runs-on: ubuntu-24.04
24-
continue-on-error: ${{ matrix.allow_failure }}
25-
timeout-minutes: 15
26-
permissions:
27-
contents: read
28-
security-events: write
29-
env:
30-
TOXENV: ${{ matrix.name }}
31-
steps:
32-
- uses: actions/checkout@v5
33-
with:
34-
persist-credentials: false
35-
36-
- uses: actions/setup-python@v6
37-
with:
38-
python-version: ${{ matrix.python }}
39-
40-
- name: Setup mysql
41-
if: contains(matrix.name, 'mysql')
42-
run: |
43-
sudo systemctl start mysql.service
44-
echo "TEST_DB_USER=root" >> $GITHUB_ENV
45-
echo "TEST_DB_PASSWORD=root" >> $GITHUB_ENV
46-
47-
- name: Setup postgresql
48-
if: contains(matrix.name, 'postgres')
49-
run: |
50-
sudo systemctl start postgresql.service
51-
sudo -u postgres createuser --createdb $USER
52-
53-
- name: Install dependencies
54-
run: |
55-
python -m pip install uv
56-
uv tool install tox==4.28.4 --with tox-uv
57-
58-
- name: Run tox
59-
run: tox
60-
61-
- name: Upload zizmor SARIF report into the GitHub repo code scanning
62-
if: contains(matrix.name, 'linting')
63-
uses: github/codeql-action/upload-sarif@v4
64-
with:
65-
sarif_file: zizmor.sarif
66-
category: zizmor
67-
68-
- name: Report coverage
69-
if: contains(matrix.name, 'coverage')
70-
uses: codecov/codecov-action@v5
71-
with:
72-
fail_ci_if_error: true
73-
files: ./coverage.xml
74-
token: ${{ secrets.CODECOV_TOKEN }}
75-
76-
strategy:
77-
fail-fast: false
78-
matrix:
79-
include:
80-
- name: linting,docs
81-
python: '3.13'
82-
allow_failure: false
83-
84-
# Explicitly test min pytest.
85-
- name: py313-dj52-sqlite-pytestmin-coverage
86-
python: '3.13'
87-
allow_failure: false
88-
89-
- name: py314-djmain-postgres-xdist-coverage
90-
python: '3.14'
91-
allow_failure: true
92-
93-
- name: py314-dj52-postgres-xdist-coverage
94-
python: '3.14'
95-
allow_failure: false
96-
97-
- name: py313-dj52-postgres-xdist-coverage
98-
python: '3.13'
99-
allow_failure: false
100-
101-
- name: py313-dj51-postgres-xdist-coverage
102-
python: '3.13'
103-
allow_failure: false
104-
105-
- name: py312-dj42-postgres-xdist-coverage
106-
python: '3.12'
107-
allow_failure: false
108-
109-
- name: py311-dj50-postgres-xdist-coverage
110-
python: '3.11'
111-
allow_failure: false
112-
113-
- name: py311-dj42-postgres-xdist-coverage
114-
python: '3.11'
115-
allow_failure: false
116-
117-
- name: py310-dj52-postgres-xdist-coverage
118-
python: '3.10'
119-
allow_failure: false
120-
121-
- name: py310-dj51-postgres-xdist-coverage
122-
python: '3.10'
123-
allow_failure: false
124-
125-
- name: py310-dj42-postgres-xdist-coverage
126-
python: '3.10'
127-
allow_failure: false
128-
129-
- name: py311-dj51-mysql-coverage
130-
python: '3.11'
131-
allow_failure: false
132-
133-
- name: py310-dj42-mysql-coverage
134-
python: '3.10'
135-
allow_failure: false
136-
137-
- name: py313-djmain-sqlite-coverage
138-
python: '3.13'
139-
allow_failure: true
140-
141-
- name: py313-dj52-sqlite-coverage
142-
python: '3.13'
143-
allow_failure: false
144-
145-
- name: py312-dj51-sqlite-xdist-coverage
146-
python: '3.12'
147-
allow_failure: false
148-
149-
- name: py311-dj42-sqlite-xdist-coverage
150-
python: '3.11'
151-
allow_failure: false
152-
153-
# pypy3: not included with coverage reports (much slower then).
154-
- name: pypy3-dj42-postgres
155-
python: 'pypy3.10'
156-
allow_failure: false
157-
158-
check: # This job does nothing and is only used for the branch protection
159-
if: always()
160-
161-
needs:
162-
- test
163-
164-
runs-on: ubuntu-24.04
165-
166-
steps:
167-
- name: Decide whether the needed jobs succeeded or failed
168-
uses: re-actors/alls-green@2765efec08f0fd63e83ad900f5fd75646be69ff6
169-
with:
170-
jobs: ${{ toJSON(needs) }}

pytest_django/asserts.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import annotations
66

77
from functools import wraps
8-
from typing import TYPE_CHECKING, Any, Callable
8+
from typing import TYPE_CHECKING
99

1010
from django import VERSION
1111
from django.test import LiveServerTestCase, SimpleTestCase, TestCase, TransactionTestCase
@@ -24,6 +24,15 @@ class MessagesTestCase(MessagesTestMixin, TestCase):
2424
else:
2525
test_case = TestCase("run")
2626

27+
if TYPE_CHECKING:
28+
from collections.abc import Callable, Collection, Iterator, Sequence
29+
from contextlib import AbstractContextManager
30+
from typing import overload, Any
31+
32+
from django import forms
33+
from django.db.models import Model, QuerySet, RawQuerySet
34+
from django.http.response import HttpResponseBase
35+
2736

2837
def _wrapper(name: str) -> Callable[..., Any]:
2938
func = getattr(test_case, name)
@@ -55,14 +64,6 @@ def assertion_func(*args: Any, **kwargs: Any) -> Any:
5564

5665

5766
if TYPE_CHECKING:
58-
from collections.abc import Collection, Iterator, Sequence
59-
from contextlib import AbstractContextManager
60-
from typing import overload
61-
62-
from django import forms
63-
from django.db.models import Model, QuerySet, RawQuerySet
64-
from django.http.response import HttpResponseBase
65-
6667
def assertRedirects(
6768
response: HttpResponseBase,
6869
expected_url: str,

pytest_django/fixtures.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import os
6-
from collections.abc import Generator, Iterable, Sequence
6+
from collections.abc import Callable, Generator, Iterable, Sequence
77
from contextlib import AbstractContextManager, contextmanager
88
from functools import partial
99
from typing import TYPE_CHECKING, Protocol
@@ -16,16 +16,16 @@
1616

1717

1818
if TYPE_CHECKING:
19-
from typing import Any, Callable, Literal, Optional, Union
19+
from typing import Any, Literal, Union
2020

2121
import django
2222
import django.test
2323

2424
from . import DjangoDbBlocker
2525
from .django_compat import _User, _UserModel
2626

27-
_DjangoDbDatabases = Optional[Union[Literal["__all__"], Iterable[str]]]
28-
_DjangoDbAvailableApps = Optional[list[str]]
27+
_DjangoDbDatabases = Union[Literal["__all__"] | Iterable[str]]
28+
_DjangoDbAvailableApps = list[str] | None
2929
# transaction, reset_sequences, databases, serialized_rollback, available_apps
3030
_DjangoDb = tuple[bool, bool, _DjangoDbDatabases, bool, _DjangoDbAvailableApps]
3131

0 commit comments

Comments
 (0)