Skip to content

Commit ee71ff0

Browse files
committed
Setup mypy
1 parent 21d6148 commit ee71ff0

File tree

4 files changed

+48
-65
lines changed

4 files changed

+48
-65
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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ repos:
3636
- id: poetry-export
3737

3838
- repo: https://github.com/astral-sh/ruff-pre-commit
39-
rev: v0.1.3
39+
rev: v0.1.6
4040
hooks:
4141
- id: ruff-format
4242
- id: ruff
43+
44+
- repo: https://github.com/pre-commit/mirrors-mypy
45+
rev: v1.7.0
46+
hooks:
47+
- id: mypy
48+
additional_dependencies:
49+
- django-stubs==4.2.6

.pylintrc

Lines changed: 0 additions & 62 deletions
This file was deleted.

django_fsm/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ def get_all_transitions(self, instance_cls):
335335
for transition in meta.transitions.values():
336336
yield transition
337337

338-
def contribute_to_class(self, cls, name, **kwargs):
338+
def contribute_to_class(self, cls, name, private_only=False, **kwargs):
339339
self.base_cls = cls
340340

341-
super().contribute_to_class(cls, name, **kwargs)
341+
super().contribute_to_class(cls, name, private_only=private_only, **kwargs)
342342
setattr(cls, self.name, self.descriptor_class(self))
343343
setattr(cls, f"get_all_{self.name}_transitions", partialmethod(get_all_FIELD_transitions, field=self))
344344
setattr(cls, f"get_available_{self.name}_transitions", partialmethod(get_available_FIELD_transitions, field=self))

0 commit comments

Comments
 (0)