python-linters 0.1.4__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_linters-0.1.4 → python_linters-0.1.5}/PKG-INFO +19 -44
- {python_linters-0.1.4 → python_linters-0.1.5}/README.md +18 -39
- {python_linters-0.1.4 → python_linters-0.1.5}/pyproject.toml +1 -5
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/run_linters.py +4 -2
- {python_linters-0.1.4 → python_linters-0.1.5}/LICENSE +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/.flake8 +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/__init__.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/add_noqa.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/config_files.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/extending_ruff_toml.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/fix_code.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/getting_to_be_linted_folders.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/parse_rules.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/pyrightconfig.json +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/ruff.toml +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/ruff_rule_categories.py +0 -0
- {python_linters-0.1.4 → python_linters-0.1.5}/python_linters/ruff_rules.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-linters
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: bundling config files for linters like ruff and flake8
|
|
5
5
|
Home-page: https://github.com/dertilo/python-linters
|
|
6
6
|
License: MIT
|
|
@@ -13,12 +13,8 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Requires-Dist: basedpyright (>=1.12.5,<2.0.0)
|
|
16
|
-
Requires-Dist: black (>=23.9.1,<24.0.0)
|
|
17
|
-
Requires-Dist: flake8 (>=6.1.0,<7.0.0)
|
|
18
|
-
Requires-Dist: flake8-newspaper-style (>=0.4.3,<0.5.0)
|
|
19
16
|
Requires-Dist: ruff (>=0.0.291)
|
|
20
17
|
Requires-Dist: toml (>=0.10.2,<0.11.0)
|
|
21
|
-
Requires-Dist: wemake-python-styleguide (>=0.18.0,<0.19.0)
|
|
22
18
|
Project-URL: Repository, https://github.com/dertilo/python-linters
|
|
23
19
|
Description-Content-Type: text/markdown
|
|
24
20
|
|
|
@@ -26,11 +22,26 @@ Description-Content-Type: text/markdown
|
|
|
26
22
|
[](https://opensource.org/licenses/MIT)
|
|
27
23
|
[](https://beartype.readthedocs.io)
|
|
28
24
|
# python-linters
|
|
29
|
-
- bundles
|
|
25
|
+
- bundles ruff and basedpyright into a single poetry-script
|
|
30
26
|
- project independent linter configuration (via `ruff.toml`,`.flake8`) -> one config to rule them all
|
|
31
27
|
### use-cases:
|
|
32
28
|
1. interactively learning python code quality standards via ruff+flake8, see [local development workflow](#2-local-development-workflow-before-pushing-to-ci-pipeline)
|
|
33
29
|
2. enforcing minimal quality-standards via a "lint-stage" in a ci-pipeline, see [setup for ci-pipeline](#3-setup-for-ci-pipeline)
|
|
30
|
+
## 0. motivation:
|
|
31
|
+
### Python is a Bicycle!
|
|
32
|
+
- initial idea of python: `Bridge the gap between the shell and C.`[see](https://www.artima.com/articles/pythons-design-goals)
|
|
33
|
+

|
|
34
|
+
### run-time "safety"
|
|
35
|
+
- type and data validation at runtime
|
|
36
|
+
- pytests run your code -> runtime
|
|
37
|
+

|
|
38
|
+
### lint-time "safety"
|
|
39
|
+
- linting and static type checking
|
|
40
|
+

|
|
41
|
+
- flake8 already fell down!
|
|
42
|
+
### more "safety" via shorter feed-back loops
|
|
43
|
+

|
|
44
|
+
|
|
34
45
|
|
|
35
46
|
## 1. install (via poetry)
|
|
36
47
|
1. in `pyproject.toml` add to dependencies
|
|
@@ -83,7 +94,7 @@ cond9 --> | complains | cond47{{"ruff"}}:::style0
|
|
|
83
94
|
cond47 --> | complains | op51[\"poetry run addnoqa"/]:::style1
|
|
84
95
|
op51 --> sub53[\"refactor your code \nOR\n keep/add noqa-comment"/]:::style1
|
|
85
96
|
sub53 --> op2
|
|
86
|
-
cond47 --> | is happy | cond58{{"
|
|
97
|
+
cond47 --> | is happy | cond58{{"pyright"}}:::style0
|
|
87
98
|
cond58 --> | complains | sub53
|
|
88
99
|
cond58 --> | is happy | sub66["git commit"]
|
|
89
100
|
sub66 --> sub80
|
|
@@ -137,19 +148,6 @@ All done! ✨ 🍰 ✨
|
|
|
137
148
|
folders_to_be_linted=['whisper_streaming', 'tests']
|
|
138
149
|
```
|
|
139
150
|
|
|
140
|
-
### pythonlinter black is not happy
|
|
141
|
-
```commandline
|
|
142
|
-
poetry run pythonlinter
|
|
143
|
-
linter-order: black->ruff->flake8
|
|
144
|
-
folders_tobelinted=['whisper_streaming', 'tests']
|
|
145
|
-
running black
|
|
146
|
-
would reformat <somehwere>/whisper-streaming/whisper_streaming/post_asr_preparations.py
|
|
147
|
-
would reformat <somehwere>/whisper-streaming/whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py
|
|
148
|
-
|
|
149
|
-
Oh no! 💥 💔 💥
|
|
150
|
-
2 files would be reformatted, 20 files would be left unchanged.
|
|
151
|
-
python_linters.run_linters.LinterException: 💩 black is not happy! 💩
|
|
152
|
-
```
|
|
153
151
|
### pythonlinter ruff is not happy
|
|
154
152
|
- complains about
|
|
155
153
|
- an unused argument
|
|
@@ -170,27 +168,6 @@ Found 4 errors.
|
|
|
170
168
|
No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option).
|
|
171
169
|
python_linters.run_linters.LinterException: 💩 ruff is not happy! 💩
|
|
172
170
|
```
|
|
173
|
-
### pythonlinter flake8 is not happy
|
|
174
|
-
- complains about too many methods in a class and wrong position of a function in a module
|
|
175
|
-
```commandline
|
|
176
|
-
poetry run pythonlinter
|
|
177
|
-
linter-order: black->ruff->flake8
|
|
178
|
-
folders_tobelinted=['whisper_streaming', 'tests']
|
|
179
|
-
running black
|
|
180
|
-
All done! ✨ 🍰 ✨
|
|
181
|
-
22 files would be left unchanged.
|
|
182
|
-
|
|
183
|
-
passed black linter! ✨ 🍰 ✨
|
|
184
|
-
|
|
185
|
-
running ruff
|
|
186
|
-
|
|
187
|
-
passed ruff linter! ✨ 🍰 ✨
|
|
188
|
-
|
|
189
|
-
running flake8
|
|
190
|
-
whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py:111:1: WPS214 Found too many methods: 10 > 9
|
|
191
|
-
tests/conftest.py:35:8: NEW100 newspaper style: function is_in_docker_container defined in line 16 should be moved down
|
|
192
|
-
python_linters.run_linters.LinterException: 💩 flake8 is not happy! 💩
|
|
193
|
-
```
|
|
194
171
|
### addnoqa example
|
|
195
172
|
- only shows how many noqas it added (`3`) and how many files it left unchanged (`22`)
|
|
196
173
|
```commandline
|
|
@@ -203,11 +180,9 @@ addnoqa iteration: 0
|
|
|
203
180
|
```
|
|
204
181
|
- it adds noqas like this one:
|
|
205
182
|
```python
|
|
206
|
-
def foobar(x):
|
|
183
|
+
def foobar(x): # noqa: ANN001, ANN202
|
|
207
184
|
return "whatever"
|
|
208
185
|
|
|
209
|
-
from faster_whisper.transcribe import Segment as FasterWhisperSegment # noqa: E402
|
|
210
|
-
|
|
211
186
|
```
|
|
212
187
|
# IDE integration
|
|
213
188
|
## manual vscode integration
|
|
@@ -2,11 +2,26 @@
|
|
|
2
2
|
[](https://opensource.org/licenses/MIT)
|
|
3
3
|
[](https://beartype.readthedocs.io)
|
|
4
4
|
# python-linters
|
|
5
|
-
- bundles
|
|
5
|
+
- bundles ruff and basedpyright into a single poetry-script
|
|
6
6
|
- project independent linter configuration (via `ruff.toml`,`.flake8`) -> one config to rule them all
|
|
7
7
|
### use-cases:
|
|
8
8
|
1. interactively learning python code quality standards via ruff+flake8, see [local development workflow](#2-local-development-workflow-before-pushing-to-ci-pipeline)
|
|
9
9
|
2. enforcing minimal quality-standards via a "lint-stage" in a ci-pipeline, see [setup for ci-pipeline](#3-setup-for-ci-pipeline)
|
|
10
|
+
## 0. motivation:
|
|
11
|
+
### Python is a Bicycle!
|
|
12
|
+
- initial idea of python: `Bridge the gap between the shell and C.`[see](https://www.artima.com/articles/pythons-design-goals)
|
|
13
|
+

|
|
14
|
+
### run-time "safety"
|
|
15
|
+
- type and data validation at runtime
|
|
16
|
+
- pytests run your code -> runtime
|
|
17
|
+

|
|
18
|
+
### lint-time "safety"
|
|
19
|
+
- linting and static type checking
|
|
20
|
+

|
|
21
|
+
- flake8 already fell down!
|
|
22
|
+
### more "safety" via shorter feed-back loops
|
|
23
|
+

|
|
24
|
+
|
|
10
25
|
|
|
11
26
|
## 1. install (via poetry)
|
|
12
27
|
1. in `pyproject.toml` add to dependencies
|
|
@@ -59,7 +74,7 @@ cond9 --> | complains | cond47{{"ruff"}}:::style0
|
|
|
59
74
|
cond47 --> | complains | op51[\"poetry run addnoqa"/]:::style1
|
|
60
75
|
op51 --> sub53[\"refactor your code \nOR\n keep/add noqa-comment"/]:::style1
|
|
61
76
|
sub53 --> op2
|
|
62
|
-
cond47 --> | is happy | cond58{{"
|
|
77
|
+
cond47 --> | is happy | cond58{{"pyright"}}:::style0
|
|
63
78
|
cond58 --> | complains | sub53
|
|
64
79
|
cond58 --> | is happy | sub66["git commit"]
|
|
65
80
|
sub66 --> sub80
|
|
@@ -113,19 +128,6 @@ All done! ✨ 🍰 ✨
|
|
|
113
128
|
folders_to_be_linted=['whisper_streaming', 'tests']
|
|
114
129
|
```
|
|
115
130
|
|
|
116
|
-
### pythonlinter black is not happy
|
|
117
|
-
```commandline
|
|
118
|
-
poetry run pythonlinter
|
|
119
|
-
linter-order: black->ruff->flake8
|
|
120
|
-
folders_tobelinted=['whisper_streaming', 'tests']
|
|
121
|
-
running black
|
|
122
|
-
would reformat <somehwere>/whisper-streaming/whisper_streaming/post_asr_preparations.py
|
|
123
|
-
would reformat <somehwere>/whisper-streaming/whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py
|
|
124
|
-
|
|
125
|
-
Oh no! 💥 💔 💥
|
|
126
|
-
2 files would be reformatted, 20 files would be left unchanged.
|
|
127
|
-
python_linters.run_linters.LinterException: 💩 black is not happy! 💩
|
|
128
|
-
```
|
|
129
131
|
### pythonlinter ruff is not happy
|
|
130
132
|
- complains about
|
|
131
133
|
- an unused argument
|
|
@@ -146,27 +148,6 @@ Found 4 errors.
|
|
|
146
148
|
No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option).
|
|
147
149
|
python_linters.run_linters.LinterException: 💩 ruff is not happy! 💩
|
|
148
150
|
```
|
|
149
|
-
### pythonlinter flake8 is not happy
|
|
150
|
-
- complains about too many methods in a class and wrong position of a function in a module
|
|
151
|
-
```commandline
|
|
152
|
-
poetry run pythonlinter
|
|
153
|
-
linter-order: black->ruff->flake8
|
|
154
|
-
folders_tobelinted=['whisper_streaming', 'tests']
|
|
155
|
-
running black
|
|
156
|
-
All done! ✨ 🍰 ✨
|
|
157
|
-
22 files would be left unchanged.
|
|
158
|
-
|
|
159
|
-
passed black linter! ✨ 🍰 ✨
|
|
160
|
-
|
|
161
|
-
running ruff
|
|
162
|
-
|
|
163
|
-
passed ruff linter! ✨ 🍰 ✨
|
|
164
|
-
|
|
165
|
-
running flake8
|
|
166
|
-
whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py:111:1: WPS214 Found too many methods: 10 > 9
|
|
167
|
-
tests/conftest.py:35:8: NEW100 newspaper style: function is_in_docker_container defined in line 16 should be moved down
|
|
168
|
-
python_linters.run_linters.LinterException: 💩 flake8 is not happy! 💩
|
|
169
|
-
```
|
|
170
151
|
### addnoqa example
|
|
171
152
|
- only shows how many noqas it added (`3`) and how many files it left unchanged (`22`)
|
|
172
153
|
```commandline
|
|
@@ -179,11 +160,9 @@ addnoqa iteration: 0
|
|
|
179
160
|
```
|
|
180
161
|
- it adds noqas like this one:
|
|
181
162
|
```python
|
|
182
|
-
def foobar(x):
|
|
163
|
+
def foobar(x): # noqa: ANN001, ANN202
|
|
183
164
|
return "whatever"
|
|
184
165
|
|
|
185
|
-
from faster_whisper.transcribe import Segment as FasterWhisperSegment # noqa: E402
|
|
186
|
-
|
|
187
166
|
```
|
|
188
167
|
# IDE integration
|
|
189
168
|
## manual vscode integration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "python-linters"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.5"
|
|
4
4
|
description = "bundling config files for linters like ruff and flake8"
|
|
5
5
|
authors = ["Tilo Himmelsbach <dertilo@gmail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -16,11 +16,7 @@ addnoqa = 'python_linters.add_noqa:main'
|
|
|
16
16
|
[tool.poetry.dependencies]
|
|
17
17
|
python = "^3.10"
|
|
18
18
|
toml = "^0.10.2"
|
|
19
|
-
flake8 = "^6.1.0"
|
|
20
|
-
wemake-python-styleguide = "^0.18.0"
|
|
21
19
|
ruff = ">=0.0.291"
|
|
22
|
-
black = "^23.9.1"
|
|
23
|
-
flake8-newspaper-style = "^0.4.3"
|
|
24
20
|
basedpyright = "^1.12.5"
|
|
25
21
|
|
|
26
22
|
[tool.poetry.group.dev.dependencies]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import subprocess
|
|
2
2
|
import sys
|
|
3
3
|
|
|
4
|
-
from python_linters.config_files import
|
|
4
|
+
from python_linters.config_files import PYRIGHT_CONFIG_FILE
|
|
5
5
|
from python_linters.extending_ruff_toml import create_extended_ruff_toml
|
|
6
6
|
from python_linters.getting_to_be_linted_folders import get_folders_to_be_linted
|
|
7
7
|
|
|
@@ -20,7 +20,9 @@ NAME2LINTER = {
|
|
|
20
20
|
"ruff-format": lambda folders_tobelinted: f"ruff format --check {' '.join(folders_tobelinted)}",
|
|
21
21
|
"ruff": lambda folders_tobelinted: f"poetry run ruff check {' '.join(folders_tobelinted)} --config={create_extended_ruff_toml()}",
|
|
22
22
|
"basedpyright": lambda folders_tobelinted: f"cp -n {PYRIGHT_CONFIG_FILE} ./ && poetry run basedpyright {' '.join(folders_tobelinted)} --gitlabcodequality report.json --level $(cat pyrightlevel.txt 2>/dev/null || echo 'warning')",
|
|
23
|
-
|
|
23
|
+
# most flake8 linters are already included in ruff
|
|
24
|
+
# the news-paper-style function ordering rule is currently only enforced by a flake8 plugin but its not that important
|
|
25
|
+
# "flake8": lambda folders_tobelinted: f"poetry run flake8 --config={FLAKE8_CONFIG_FILE} {' '.join(folders_tobelinted)}",
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_linters-0.1.4 → python_linters-0.1.5}/python_linters/getting_to_be_linted_folders.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|