Skip to content

Commit 30602a2

Browse files
committed
tox: update ruff, mypy
1 parent a39b910 commit 30602a2

12 files changed

+57
-68
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ ignore = [
144144
"PT023", # Use `@pytest.mark.django_db()` over `@pytest.mark.django_db`
145145
]
146146

147-
[tool.ruff.isort]
147+
[tool.ruff.lint.isort]
148148
forced-separate = [
149149
"tests",
150150
"pytest_django",

pytest_django/asserts.py

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Dynamically load all Django assertion cases and expose them for importing.
33
"""
4+
45
from __future__ import annotations
56

67
from functools import wraps
@@ -64,15 +65,13 @@ def assertRedirects(
6465
target_status_code: int = ...,
6566
msg_prefix: str = ...,
6667
fetch_redirect_response: bool = ...,
67-
) -> None:
68-
...
68+
) -> None: ...
6969

7070
def assertURLEqual(
7171
url1: str,
7272
url2: str,
7373
msg_prefix: str = ...,
74-
) -> None:
75-
...
74+
) -> None: ...
7675

7776
def assertContains(
7877
response: HttpResponseBase,
@@ -81,65 +80,57 @@ def assertContains(
8180
status_code: int = ...,
8281
msg_prefix: str = ...,
8382
html: bool = False,
84-
) -> None:
85-
...
83+
) -> None: ...
8684

8785
def assertNotContains(
8886
response: HttpResponseBase,
8987
text: object,
9088
status_code: int = ...,
9189
msg_prefix: str = ...,
9290
html: bool = False,
93-
) -> None:
94-
...
91+
) -> None: ...
9592

9693
def assertFormError(
9794
form: forms.BaseForm,
9895
field: str | None,
9996
errors: str | Sequence[str],
10097
msg_prefix: str = ...,
101-
) -> None:
102-
...
98+
) -> None: ...
10399

104100
def assertFormSetError(
105101
formset: forms.BaseFormSet,
106102
form_index: int | None,
107103
field: str | None,
108104
errors: str | Sequence[str],
109105
msg_prefix: str = ...,
110-
) -> None:
111-
...
106+
) -> None: ...
112107

113108
def assertTemplateUsed(
114109
response: HttpResponseBase | str | None = ...,
115110
template_name: str | None = ...,
116111
msg_prefix: str = ...,
117112
count: int | None = ...,
118-
):
119-
...
113+
): ...
120114

121115
def assertTemplateNotUsed(
122116
response: HttpResponseBase | str | None = ...,
123117
template_name: str | None = ...,
124118
msg_prefix: str = ...,
125-
):
126-
...
119+
): ...
127120

128121
def assertRaisesMessage(
129122
expected_exception: type[Exception],
130123
expected_message: str,
131124
*args,
132125
**kwargs,
133-
):
134-
...
126+
): ...
135127

136128
def assertWarnsMessage(
137129
expected_warning: Warning,
138130
expected_message: str,
139131
*args,
140132
**kwargs,
141-
):
142-
...
133+
): ...
143134

144135
def assertFieldOutput(
145136
fieldclass,
@@ -148,58 +139,50 @@ def assertFieldOutput(
148139
field_args=...,
149140
field_kwargs=...,
150141
empty_value: str = ...,
151-
) -> None:
152-
...
142+
) -> None: ...
153143

154144
def assertHTMLEqual(
155145
html1: str,
156146
html2: str,
157147
msg: str | None = ...,
158-
) -> None:
159-
...
148+
) -> None: ...
160149

161150
def assertHTMLNotEqual(
162151
html1: str,
163152
html2: str,
164153
msg: str | None = ...,
165-
) -> None:
166-
...
154+
) -> None: ...
167155

168156
def assertInHTML(
169157
needle: str,
170158
haystack: str,
171159
count: int | None = ...,
172160
msg_prefix: str = ...,
173-
) -> None:
174-
...
161+
) -> None: ...
175162

176163
def assertJSONEqual(
177164
raw: str,
178165
expected_data: Any,
179166
msg: str | None = ...,
180-
) -> None:
181-
...
167+
) -> None: ...
182168

183169
def assertJSONNotEqual(
184170
raw: str,
185171
expected_data: Any,
186172
msg: str | None = ...,
187-
) -> None:
188-
...
173+
) -> None: ...
189174

190175
def assertXMLEqual(
191176
xml1: str,
192177
xml2: str,
193178
msg: str | None = ...,
194-
) -> None:
195-
...
179+
) -> None: ...
196180

197181
def assertXMLNotEqual(
198182
xml1: str,
199183
xml2: str,
200184
msg: str | None = ...,
201-
) -> None:
202-
...
185+
) -> None: ...
203186

204187
# Removed in Django 5.1: use assertQuerySetEqual.
205188
def assertQuerysetEqual(
@@ -208,36 +191,31 @@ def assertQuerysetEqual(
208191
transform=...,
209192
ordered: bool = ...,
210193
msg: str | None = ...,
211-
) -> None:
212-
...
194+
) -> None: ...
213195

214196
def assertQuerySetEqual(
215197
qs,
216198
values,
217199
transform=...,
218200
ordered: bool = ...,
219201
msg: str | None = ...,
220-
) -> None:
221-
...
202+
) -> None: ...
222203

223204
def assertNumQueries(
224205
num: int,
225206
func=...,
226207
*args,
227208
using: str = ...,
228209
**kwargs,
229-
):
230-
...
210+
): ...
231211

232212
# Added in Django 5.0.
233213
def assertMessages(
234214
response: HttpResponseBase,
235215
expected_messages: Sequence[Message],
236216
*args,
237217
ordered: bool = ...,
238-
) -> None:
239-
...
218+
) -> None: ...
240219

241220
# Fallback in case Django adds new asserts.
242-
def __getattr__(name: str) -> Callable[..., Any]:
243-
...
221+
def __getattr__(name: str) -> Callable[..., Any]: ...

pytest_django/fixtures.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""All pytest-django fixtures"""
2+
23
from __future__ import annotations
34

45
import os

pytest_django/lazy_django.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Helpers to load Django lazily when Django settings can't be configured.
33
"""
4+
45
from __future__ import annotations
56

67
import os

pytest_django/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This plugin handles creating and destroying the test environment and
44
test database and provides some useful text fixtures.
55
"""
6+
67
from __future__ import annotations
78

89
import contextlib

tests/helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ def create_test_module( # type: ignore[empty-body]
1010
self,
1111
test_code: str,
1212
filename: str = ...,
13-
) -> Path:
14-
...
13+
) -> Path: ...
1514

1615
def create_app_file(self, code: str, filename: str) -> Path: # type: ignore[empty-body]
1716
...

tests/test_asserts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Tests the dynamic loading of all Django assertion cases.
33
"""
4+
45
from __future__ import annotations
56

67
import inspect

tests/test_django_configurations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
If these tests fail you probably forgot to install django-configurations.
44
"""
5+
56
import pytest
67

78

tests/test_django_settings_module.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -377,32 +377,38 @@ def test_django_debug_mode_keep(
377377
monkeypatch.delenv("DJANGO_SETTINGS_MODULE")
378378
pytester.makeini(
379379
"""
380-
[pytest]
381-
django_debug_mode = keep
382-
"""
380+
[pytest]
381+
django_debug_mode = keep
382+
"""
383383
)
384384
pytester.makeconftest(
385-
"""
385+
f"""
386386
from django.conf import settings
387387
388388
def pytest_configure():
389-
settings.configure(SECRET_KEY='set from pytest_configure',
390-
DEBUG=%s,
391-
DATABASES={'default': {
392-
'ENGINE': 'django.db.backends.sqlite3',
393-
'NAME': ':memory:'}},
394-
INSTALLED_APPS=['django.contrib.auth',
395-
'django.contrib.contenttypes',])
396-
"""
397-
% settings_debug
389+
settings.configure(
390+
SECRET_KEY='set from pytest_configure',
391+
DEBUG={settings_debug},
392+
DATABASES={{
393+
'default': {{
394+
'ENGINE': 'django.db.backends.sqlite3',
395+
'NAME': ':memory:',
396+
}},
397+
}},
398+
INSTALLED_APPS=[
399+
'django.contrib.auth',
400+
'django.contrib.contenttypes',
401+
],
402+
)
403+
"""
398404
)
399405

400406
pytester.makepyfile(
401407
f"""
402408
from django.conf import settings
403409
def test_debug_is_false():
404410
assert settings.DEBUG is {settings_debug}
405-
"""
411+
"""
406412
)
407413

408414
r = pytester.runpytest_subprocess()
@@ -414,7 +420,7 @@ def test_debug_is_false():
414420
INSTALLED_APPS = [
415421
'tpkg.app.apps.TestApp',
416422
]
417-
"""
423+
"""
418424
)
419425
def test_django_setup_sequence(django_pytester) -> None:
420426
django_pytester.create_app_file(

tests/test_environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_for_invalid_template(client):
154154
"""
155155
)
156156
def test_invalid_template_variable_behaves_normally_when_ignored(
157-
django_pytester: DjangoPytester
157+
django_pytester: DjangoPytester,
158158
) -> None:
159159
django_pytester.create_app_file(
160160
"<div>{{ invalid_var }}</div>", "templates/invalid_template_base.html"

tests/test_fixtures.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Not quite all fixtures are tested here, the db and transactional_db
44
fixtures are tested in test_database.
55
"""
6+
67
import socket
78
from contextlib import contextmanager
89
from typing import Generator

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ commands =
5252
[testenv:linting]
5353
extras =
5454
deps =
55-
ruff==0.1.3
56-
mypy==1.6.1
55+
ruff==0.6.3
56+
mypy==1.11.2
5757
commands =
58-
ruff check --statistics {posargs:pytest_django pytest_django_test tests}
58+
ruff check {posargs:pytest_django pytest_django_test tests}
5959
ruff format --quiet --diff {posargs:pytest_django pytest_django_test tests}
6060
mypy {posargs:pytest_django pytest_django_test tests}
6161

0 commit comments

Comments
 (0)