Skip to content

Commit

Permalink
Updated pre-commit versions and applied lint changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schilling committed Nov 19, 2024
1 parent c4a2fbc commit ca9ff34
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.9
rev: 1.7.10
hooks:
- id: bandit
exclude: /.*tests/

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.9
Expand All @@ -25,7 +25,7 @@ repos:
- id: isort

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: requirements-txt-fixer
files: requirements/.*\.txt$
Expand All @@ -44,7 +44,7 @@ repos:
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.19
rev: v0.23
hooks:
- id: validate-pyproject

Expand All @@ -56,7 +56,7 @@ repos:
- "--strict"

- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py39-plus]
3 changes: 2 additions & 1 deletion simple_history/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Sequence
from collections.abc import Sequence
from typing import Any

from django import http
from django.apps import apps as django_apps
Expand Down
11 changes: 6 additions & 5 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import importlib
import uuid
import warnings
from collections.abc import Iterable, Sequence
from dataclasses import dataclass
from functools import partial
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Sequence, Type, Union
from typing import TYPE_CHECKING, Any, Dict, List, Type, Union

import django
from django.apps import apps
Expand Down Expand Up @@ -1012,7 +1013,7 @@ def _get_field_changes_for_diff(
old_history: "HistoricalChanges",
fields: Iterable[str],
foreign_keys_are_objs: bool,
) -> List["ModelChange"]:
) -> list["ModelChange"]:
"""Helper method for ``diff_against()``."""
changes = []

Expand Down Expand Up @@ -1053,7 +1054,7 @@ def _get_m2m_field_changes_for_diff(
old_history: "HistoricalChanges",
m2m_fields: Iterable[str],
foreign_keys_are_objs: bool,
) -> List["ModelChange"]:
) -> list["ModelChange"]:
"""Helper method for ``diff_against()``."""
changes = []

Expand Down Expand Up @@ -1122,7 +1123,7 @@ def get_value(obj, through_field):

@dataclass(frozen=True)
class DeletedObject:
model: Type[models.Model]
model: type[models.Model]
pk: Any

def __str__(self):
Expand All @@ -1147,7 +1148,7 @@ def __str__(self):
# The PK of the through model's related objects.
#
# - Any of the other possible values of a model field.
ModelChangeValue = Union[Any, DeletedObject, List[Dict[str, Union[Any, DeletedObject]]]]
ModelChangeValue = Union[Any, DeletedObject, list[dict[str, Union[Any, DeletedObject]]]]


@dataclass(frozen=True)
Expand Down
8 changes: 4 additions & 4 deletions simple_history/template_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class HistoricalRecordContextHelper:

def __init__(
self,
model: Type[Model],
model: type[Model],
historical_record: HistoricalChanges,
*,
max_displayed_delta_change_chars=DEFAULT_MAX_DISPLAYED_DELTA_CHANGE_CHARS,
Expand All @@ -50,7 +50,7 @@ def __init__(

self.max_displayed_delta_change_chars = max_displayed_delta_change_chars

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

def stringify_delta_change_values(
self, change: ModelChange, old: Any, new: Any
) -> Tuple[SafeString, SafeString]:
) -> tuple[SafeString, SafeString]:
"""
Called by ``format_delta_change()`` after ``old`` and ``new`` have been
prepared by ``prepare_delta_change_value()``.
Expand Down Expand Up @@ -196,7 +196,7 @@ def __init__(
)
assert self.min_diff_len >= 0 # nosec

def common_shorten_repr(self, *args: Any) -> Tuple[str, ...]:
def common_shorten_repr(self, *args: Any) -> tuple[str, ...]:
"""
Returns ``args`` with each element converted into a string representation.
If any of the strings are longer than ``self.max_length``, they're all shortened
Expand Down
2 changes: 1 addition & 1 deletion simple_history/tests/tests/test_template_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_context_dict(
)

def test__context_for_delta_changes__preserves_html_safe_strings(self):
def get_context_dict_old_and_new(old_value, new_value) -> Tuple[str, str]:
def get_context_dict_old_and_new(old_value, new_value) -> tuple[str, str]:
# The field doesn't really matter, as long as it exists on the model
# passed to `HistoricalRecordContextHelper`
change = ModelChange("question", old_value, new_value)
Expand Down
2 changes: 1 addition & 1 deletion simple_history/tests/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class HistoricalTestCase(TestCase):
def assertRecordValues(self, record, klass: Type[Model], values_dict: dict):
def assertRecordValues(self, record, klass: type[Model], values_dict: dict):
"""
Fail if ``record`` doesn't contain the field values in ``values_dict``.
``record.history_object`` is also checked.
Expand Down

0 comments on commit ca9ff34

Please sign in to comment.