Skip to content

Commit 8e77aac

Browse files
committed
Step 8
1 parent 94e7105 commit 8e77aac

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ repos:
4949
- id: ruff
5050

5151
- repo: https://github.com/pre-commit/mirrors-mypy
52-
rev: v1.7.1
52+
rev: v1.10.0
5353
hooks:
5454
- id: mypy
5555
additional_dependencies:
56-
- django-stubs==4.2.6
56+
- django-stubs==5.0.0
5757
- django-guardian

django_fsm/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ def has_perm(self, instance: _Instance, user: UserWithPermissions) -> bool:
122122
else:
123123
return False
124124

125-
def __hash__(self):
125+
def __hash__(self) -> int:
126126
return hash(self.name)
127127

128-
def __eq__(self, other):
128+
def __eq__(self, other: object) -> bool:
129129
if isinstance(other, str):
130130
return other == self.name
131131
if isinstance(other, Transition):
@@ -309,7 +309,7 @@ def deconstruct(self) -> Any:
309309
def get_state(self, instance: _Instance) -> Any:
310310
# The state field may be deferred. We delegate the logic of figuring this out
311311
# and loading the deferred field on-demand to Django's built-in DeferredAttribute class.
312-
return DeferredAttribute(self).__get__(instance) # type: ignore[attr-defined]
312+
return DeferredAttribute(self).__get__(instance)
313313

314314
def set_state(self, instance: _Instance, state: str) -> None:
315315
instance.__dict__[self.name] = state
@@ -479,14 +479,14 @@ class FSMModelMixin(_FSMModel):
479479
Mixin that allows refresh_from_db for models with fsm protected fields
480480
"""
481481

482-
def _get_protected_fsm_fields(self):
483-
def is_fsm_and_protected(f):
482+
def _get_protected_fsm_fields(self) -> set[str]:
483+
def is_fsm_and_protected(f: object) -> Any:
484484
return isinstance(f, FSMFieldMixin) and f.protected
485485

486-
protected_fields = filter(is_fsm_and_protected, self._meta.concrete_fields)
486+
protected_fields: Iterable[Any] = filter(is_fsm_and_protected, self._meta.concrete_fields) # type: ignore[attr-defined, arg-type]
487487
return {f.attname for f in protected_fields}
488488

489-
def refresh_from_db(self, *args, **kwargs):
489+
def refresh_from_db(self, *args: Any, **kwargs: Any) -> None:
490490
fields = kwargs.pop("fields", None)
491491

492492
# Use provided fields, if not set then reload all non-deferred fields.0
@@ -495,7 +495,7 @@ def refresh_from_db(self, *args, **kwargs):
495495
protected_fields = self._get_protected_fsm_fields()
496496
skipped_fields = deferred_fields.union(protected_fields)
497497

498-
fields = [f.attname for f in self._meta.concrete_fields if f.attname not in skipped_fields]
498+
fields = [f.attname for f in self._meta.concrete_fields if f.attname not in skipped_fields] # type: ignore[attr-defined]
499499

500500
kwargs["fields"] = fields
501501
super().refresh_from_db(*args, **kwargs)
@@ -538,9 +538,9 @@ def state_fields(self) -> Iterable[Any]:
538538
def _do_update(
539539
self,
540540
base_qs: QuerySet[Self],
541-
using: Any,
541+
using: str | None,
542542
pk_val: Any,
543-
values: Collection[Any] | None,
543+
values: Collection[tuple[_Field, type[models.Model] | None, Any]],
544544
update_fields: Iterable[str] | None,
545545
forced_update: bool,
546546
) -> bool:
@@ -553,7 +553,7 @@ def _do_update(
553553
# state filter will be used to narrow down the standard filter checking only PK
554554
state_filter = {field.attname: self.__initial_states[field.attname] for field in filter_on}
555555

556-
updated: bool = super()._do_update( # type: ignore[misc]
556+
updated: bool = super()._do_update(
557557
base_qs=base_qs.filter(**state_filter),
558558
using=using,
559559
pk_val=pk_val,

0 commit comments

Comments
 (0)