Skip to content

Commit e0d6723

Browse files
tim-schillingddabble
authored andcommitted
Updated pre-commit versions and applied lint changes.
1 parent da4c2f2 commit e0d6723

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
repos:
33
- repo: https://github.com/PyCQA/bandit
4-
rev: 1.7.9
4+
rev: 1.7.10
55
hooks:
66
- id: bandit
77
exclude: /.*tests/
88

99
- repo: https://github.com/psf/black-pre-commit-mirror
10-
rev: 24.8.0
10+
rev: 24.10.0
1111
hooks:
1212
- id: black
1313
language_version: python3.9
@@ -25,7 +25,7 @@ repos:
2525
- id: isort
2626

2727
- repo: https://github.com/pre-commit/pre-commit-hooks
28-
rev: v4.6.0
28+
rev: v5.0.0
2929
hooks:
3030
- id: requirements-txt-fixer
3131
files: requirements/.*\.txt$
@@ -44,7 +44,7 @@ repos:
4444
hooks:
4545
- id: pyproject-fmt
4646
- repo: https://github.com/abravalheri/validate-pyproject
47-
rev: v0.19
47+
rev: v0.23
4848
hooks:
4949
- id: validate-pyproject
5050

@@ -56,7 +56,7 @@ repos:
5656
- "--strict"
5757

5858
- repo: https://github.com/asottile/pyupgrade
59-
rev: v3.17.0
59+
rev: v3.19.0
6060
hooks:
6161
- id: pyupgrade
6262
args: [--py39-plus]

simple_history/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Sequence
1+
from collections.abc import Sequence
2+
from typing import Any
23

34
from django import http
45
from django.apps import apps as django_apps

simple_history/models.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import importlib
33
import uuid
44
import warnings
5+
from collections.abc import Iterable, Sequence
56
from dataclasses import dataclass
67
from functools import partial
7-
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Sequence, Type, Union
8+
from typing import TYPE_CHECKING, Any, Union
89

910
import django
1011
from django.apps import apps
@@ -1092,7 +1093,7 @@ def _get_field_changes_for_diff(
10921093
old_history: "HistoricalChanges",
10931094
fields: Iterable[str],
10941095
foreign_keys_are_objs: bool,
1095-
) -> List["ModelChange"]:
1096+
) -> list["ModelChange"]:
10961097
"""Helper method for ``diff_against()``."""
10971098
changes = []
10981099

@@ -1133,7 +1134,7 @@ def _get_m2m_field_changes_for_diff(
11331134
old_history: "HistoricalChanges",
11341135
m2m_fields: Iterable[str],
11351136
foreign_keys_are_objs: bool,
1136-
) -> List["ModelChange"]:
1137+
) -> list["ModelChange"]:
11371138
"""Helper method for ``diff_against()``."""
11381139
changes = []
11391140

@@ -1202,7 +1203,7 @@ def get_value(obj, through_field):
12021203

12031204
@dataclass(frozen=True)
12041205
class DeletedObject:
1205-
model: Type[models.Model]
1206+
model: type[models.Model]
12061207
pk: Any
12071208

12081209
def __str__(self):
@@ -1227,7 +1228,7 @@ def __str__(self):
12271228
# The PK of the through model's related objects.
12281229
#
12291230
# - Any of the other possible values of a model field.
1230-
ModelChangeValue = Union[Any, DeletedObject, List[Dict[str, Union[Any, DeletedObject]]]]
1231+
ModelChangeValue = Union[Any, DeletedObject, list[dict[str, Union[Any, DeletedObject]]]]
12311232

12321233

12331234
@dataclass(frozen=True)

simple_history/template_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dataclasses
22
from os.path import commonprefix
3-
from typing import Any, Dict, Final, List, Tuple, Type, Union
3+
from typing import Any, Final, Union
44

55
from django.db.models import ManyToManyField, Model
66
from django.utils.html import conditional_escape
@@ -40,7 +40,7 @@ class HistoricalRecordContextHelper:
4040

4141
def __init__(
4242
self,
43-
model: Type[Model],
43+
model: type[Model],
4444
historical_record: HistoricalChanges,
4545
*,
4646
max_displayed_delta_change_chars=DEFAULT_MAX_DISPLAYED_DELTA_CHANGE_CHARS,
@@ -50,7 +50,7 @@ def __init__(
5050

5151
self.max_displayed_delta_change_chars = max_displayed_delta_change_chars
5252

53-
def context_for_delta_changes(self, delta: ModelDelta) -> List[Dict[str, Any]]:
53+
def context_for_delta_changes(self, delta: ModelDelta) -> list[dict[str, Any]]:
5454
"""
5555
Return the template context for ``delta.changes``.
5656
By default, this is a list of dicts with the keys ``"field"``,
@@ -119,7 +119,7 @@ def prepare_delta_change_value(
119119

120120
def stringify_delta_change_values(
121121
self, change: ModelChange, old: Any, new: Any
122-
) -> Tuple[SafeString, SafeString]:
122+
) -> tuple[SafeString, SafeString]:
123123
"""
124124
Called by ``format_delta_change()`` after ``old`` and ``new`` have been
125125
prepared by ``prepare_delta_change_value()``.
@@ -196,7 +196,7 @@ def __init__(
196196
)
197197
assert self.min_diff_len >= 0 # nosec
198198

199-
def common_shorten_repr(self, *args: Any) -> Tuple[str, ...]:
199+
def common_shorten_repr(self, *args: Any) -> tuple[str, ...]:
200200
"""
201201
Returns ``args`` with each element converted into a string representation.
202202
If any of the strings are longer than ``self.max_length``, they're all shortened

simple_history/tests/tests/test_template_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import datetime
2-
from typing import Tuple
32

43
from django.test import TestCase
54
from django.utils.dateparse import parse_datetime
@@ -225,7 +224,7 @@ def test_context_dict(
225224
)
226225

227226
def test__context_for_delta_changes__preserves_html_safe_strings(self):
228-
def get_context_dict_old_and_new(old_value, new_value) -> Tuple[str, str]:
227+
def get_context_dict_old_and_new(old_value, new_value) -> tuple[str, str]:
229228
# The field doesn't really matter, as long as it exists on the model
230229
# passed to `HistoricalRecordContextHelper`
231230
change = ModelChange("question", old_value, new_value)

simple_history/tests/tests/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from enum import Enum
2-
from typing import Type
32

43
from django.conf import settings
54
from django.db.models import Model
@@ -15,7 +14,7 @@
1514

1615

1716
class HistoricalTestCase(TestCase):
18-
def assertRecordValues(self, record, klass: Type[Model], values_dict: dict):
17+
def assertRecordValues(self, record, klass: type[Model], values_dict: dict):
1918
"""
2019
Fail if ``record`` doesn't contain the field values in ``values_dict``.
2120
``record.history_object`` is also checked.

0 commit comments

Comments
 (0)