Skip to content

Commit 2946d55

Browse files
committed
Setup mypy
1 parent c1318d6 commit 2946d55

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

.mypy.ini

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[mypy]
2+
# Start off with these
3+
; warn_unused_configs = True
4+
; warn_redundant_casts = True
5+
; warn_unused_ignores = True
6+
7+
# Getting these passing should be easy
8+
; strict_equality = True
9+
; extra_checks = True
10+
11+
# Strongly recommend enabling this one as soon as you can
12+
; check_untyped_defs = True
13+
14+
# These shouldn't be too much additional work, but may be tricky to
15+
# get passing if you use a lot of untyped libraries
16+
; disallow_subclassing_any = True
17+
; disallow_untyped_decorators = True
18+
; disallow_any_generics = True
19+
20+
# These next few are various gradations of forcing use of type annotations
21+
; disallow_untyped_calls = True
22+
; disallow_incomplete_defs = True
23+
; disallow_untyped_defs = True
24+
25+
# This one isn't too hard to get passing, but return on investment is lower
26+
; no_implicit_reexport = True
27+
28+
# This one can be tricky to get passing if you use a lot of untyped libraries
29+
; warn_return_any = True
30+
31+
[mypy-tests.*]
32+
ignore_errors = True
33+
34+
[mypy-django_fsm.tests.*]
35+
ignore_errors = True
36+
37+
[mypy-django_fsm.management.commands.graph_transitions]
38+
ignore_errors = True

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,10 @@ repos:
4848
hooks:
4949
- id: ruff-format
5050
- id: ruff
51+
52+
- repo: https://github.com/pre-commit/mirrors-mypy
53+
rev: v1.7.0
54+
hooks:
55+
- id: mypy
56+
additional_dependencies:
57+
- django-stubs==4.2.6

django_fsm/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ def get_all_transitions(self, instance_cls):
347347
for transition in meta.transitions.values():
348348
yield transition
349349

350-
def contribute_to_class(self, cls, name, **kwargs):
350+
def contribute_to_class(self, cls, name, private_only=False, **kwargs):
351351
self.base_cls = cls
352352

353-
super().contribute_to_class(cls, name, **kwargs)
353+
super().contribute_to_class(cls, name, private_only=private_only, **kwargs)
354354
setattr(cls, self.name, self.descriptor_class(self))
355355
setattr(cls, f"get_all_{self.name}_transitions", partialmethod(get_all_FIELD_transitions, field=self))
356356
setattr(cls, f"get_available_{self.name}_transitions", partialmethod(get_available_FIELD_transitions, field=self))

0 commit comments

Comments
 (0)