-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
.pre-commit-hooks.yaml
79 lines (79 loc) · 2.99 KB
/
.pre-commit-hooks.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
- id: python-check-blanket-noqa
name: check blanket noqa
description: 'Enforce that `noqa` annotations always occur with specific codes. Sample annotations: `# noqa: F401`, `# noqa: F401,W203`'
entry: '(?i)# noqa(?!: )'
language: pygrep
types: [python]
- id: python-check-blanket-type-ignore
name: check blanket type ignore
description: 'Enforce that `# type: ignore` annotations always occur with specific codes. Sample annotations: `# type: ignore[attr-defined]`, `# type: ignore[attr-defined, name-defined]`'
entry: '# type:? *ignore(?!\[|\w)'
language: pygrep
types: [python]
- id: python-check-mock-methods
name: check for not-real mock methods
description: >-
Prevent common mistakes of `assert mck.not_called()`, `assert mck.called_once_with(...)`
and `mck.assert_called`.
language: pygrep
entry: >
(?x)(
assert .*\.(
not_called|
called_
)|
# ''.join(rf'(?<!\b{s})' for s in dir(mock) if s.endswith('Mock')))
(?<!\bAsyncMock)(?<!\bMagicMock)(?<!\bMock)(?<!\bNonCallableMagicMock)(?<!\bNonCallableMock)(?<!\bPropertyMock)
\.assert_(
any_call|
called|
called_once|
called_once_with|
called_with|
has_calls|
not_called
)($|[^(\w])
)
types: [python]
- id: python-no-eval
name: check for eval()
description: 'A quick check for the `eval()` built-in function'
entry: '\beval\('
language: pygrep
types: [python]
- id: python-no-log-warn
name: use logger.warning(
description: 'A quick check for the deprecated `.warn()` method of python loggers'
entry: '(?<!warnings)\.warn\('
language: pygrep
types: [python]
- id: python-use-type-annotations
name: type annotations not comments
description: 'Enforce that python3.6+ type annotations are used instead of type comments'
entry: '# type(?!: *ignore([^a-zA-Z0-9]|$))'
language: pygrep
types: [python]
- id: rst-backticks
name: rst ``code`` is two backticks
description: 'Detect common mistake of using single backticks when writing rst'
entry: '^(?! ).*(^| )`[^`]+`([^_]|$)'
language: pygrep
types: [rst]
- id: rst-directive-colons
name: rst directives end with two colons
description: 'Detect mistake of rst directive not ending with double colon or space before the double colon'
entry: '^\s*\.\. [a-z]+(| | :):$'
language: pygrep
types: [rst]
- id: rst-inline-touching-normal
name: rst ``inline code`` next to normal text
description: 'Detect mistake of inline code touching normal text in rst'
entry: '\w``\w'
language: pygrep
types: [rst]
- id: text-unicode-replacement-char
name: no unicode replacement chars
description: 'Forbid files which have a UTF-8 Unicode replacement character'
entry: "\uFFFD"
language: pygrep
types: [text]