@@ -33,6 +33,86 @@ repos:
33
33
- --fix
34
34
{% - endif %}
35
35
{% - if python %}
36
+ {% - if poetry_local_hooks %}
37
+ {# These hooks are copied from their respective origins in the next section,
38
+ but configured to be executed with `poetry run`, to get better integration #}
39
+ - repo: local
40
+ hooks:
41
+ - id: autoflake
42
+ name: autoflake
43
+ entry: poetry run autoflake
44
+ language: python
45
+ types: [python]
46
+ require_serial: true
47
+ args:
48
+ - --in-place
49
+ - --expand-star-imports
50
+ - --ignore-init-module-imports
51
+ - --remove-all-unused-imports
52
+ - --remove-duplicate-keys
53
+ - --remove-unused-variables
54
+ - id: pyupgrade
55
+ name: pyupgrade
56
+ description: Automatically upgrade syntax for newer versions.
57
+ entry: poetry run pyupgrade
58
+ language: python
59
+ types: [python]
60
+ - id: black
61
+ name: black
62
+ description: "Black: The uncompromising Python code formatter"
63
+ entry: poetry run black
64
+ language: python
65
+ minimum_pre_commit_version: 2.9.2
66
+ require_serial: true
67
+ types_or: [python, pyi]
68
+ - id: blacken-docs
69
+ name: blacken-docs
70
+ description: Run `black` on python code blocks in documentation files
71
+ entry: poetry run blacken-docs
72
+ language: python
73
+ language_version: python3
74
+ files: '\.(rst|md|markdown|py|tex)$'
75
+ - id: isort
76
+ name: isort
77
+ entry: poetry run isort
78
+ require_serial: true
79
+ language: python
80
+ language_version: python3
81
+ types_or: [cython, pyi, python]
82
+ minimum_pre_commit_version: '2.9.2'
83
+ args:
84
+ - --filter-files
85
+ - --settings=.
86
+ - &flake8
87
+ id: flake8
88
+ name: flake8 except __init__.py
89
+ description: '`flake8` is a command-line utility for enforcing style consistency across Python projects.'
90
+ entry: poetry run flake8
91
+ language: python
92
+ types: [python]
93
+ require_serial: true
94
+ exclude: /__init__\.py$
95
+ - <<: *flake8
96
+ name: flake8 for __init__.py
97
+ args:
98
+ # ignore unused imports in __init__.py
99
+ - --extend-ignore =F401
100
+ files: /__init__\.py$
101
+ - id: pydocstyle
102
+ name: pydocstyle
103
+ description: pydocstyle is a static analysis tool for checking compliance with Python docstring conventions.
104
+ entry: poetry run pydocstyle
105
+ language: python
106
+ types: [python]
107
+ - id: poetry-check
108
+ name: poetry-check
109
+ description: run poetry check to validate config
110
+ entry: poetry check
111
+ language: python
112
+ language_version: python3
113
+ pass_filenames: false
114
+ files: ^pyproject.toml$
115
+ {%- else %}
36
116
- repo: https: //github.com /myint /autoflake
37
117
rev: v1.4
38
118
hooks:
@@ -83,6 +163,8 @@ repos:
83
163
rev: 6.1.1
84
164
hooks:
85
165
- id: pydocstyle
166
+ additional_dependencies: [ " .[toml]" ]
167
+ {%- endif %}
86
168
{%- endif %}
87
169
{%- if terraform %}
88
170
- repo: https: //github.com /aquasecurity /tfsec
0 commit comments