python-linters 0.1.5__tar.gz → 0.1.7__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.
Files changed (23) hide show
  1. python_linters-0.1.7/.gitignore +161 -0
  2. {python_linters-0.1.5 → python_linters-0.1.7}/PKG-INFO +32 -36
  3. {python_linters-0.1.5 → python_linters-0.1.7}/README.md +20 -19
  4. python_linters-0.1.7/pyproject.toml +40 -0
  5. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/add_noqa.py +8 -6
  6. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/config_files.py +0 -2
  7. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/extending_ruff_toml.py +12 -7
  8. python_linters-0.1.7/python_linters/fix_code.py +25 -0
  9. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/getting_to_be_linted_folders.py +2 -11
  10. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/pyrightconfig.json +5 -1
  11. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/ruff.toml +69 -68
  12. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/ruff_rule_categories.py +4 -2
  13. python_linters-0.1.7/python_linters/ruff_rules.txt +1182 -0
  14. python_linters-0.1.7/python_linters/run_linters.py +49 -0
  15. python_linters-0.1.7/python_linters/utils.py +72 -0
  16. python_linters-0.1.5/pyproject.toml +0 -30
  17. python_linters-0.1.5/python_linters/.flake8 +0 -32
  18. python_linters-0.1.5/python_linters/fix_code.py +0 -29
  19. python_linters-0.1.5/python_linters/ruff_rules.txt +0 -956
  20. python_linters-0.1.5/python_linters/run_linters.py +0 -44
  21. {python_linters-0.1.5 → python_linters-0.1.7}/LICENSE +0 -0
  22. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/__init__.py +0 -0
  23. {python_linters-0.1.5 → python_linters-0.1.7}/python_linters/parse_rules.py +0 -0
@@ -0,0 +1,161 @@
1
+ _version.py
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/#use-with-ide
111
+ .pdm.toml
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ .idea/
@@ -1,31 +1,28 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-linters
3
- Version: 0.1.5
4
- Summary: bundling config files for linters like ruff and flake8
5
- Home-page: https://github.com/dertilo/python-linters
3
+ Version: 0.1.7
4
+ Summary: bundling config files for linters like ruff and pyright
5
+ Project-URL: repository, https://github.com/dertilo/python-linters
6
+ Author-email: Tilo Himmelsbach <dertilo@gmail.com>
6
7
  License: MIT
7
- Author: Tilo Himmelsbach
8
- Author-email: dertilo@gmail.com
9
- Requires-Python: >=3.10,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Requires-Dist: basedpyright (>=1.12.5,<2.0.0)
16
- Requires-Dist: ruff (>=0.0.291)
17
- Requires-Dist: toml (>=0.10.2,<0.11.0)
18
- Project-URL: Repository, https://github.com/dertilo/python-linters
8
+ License-File: LICENSE
9
+ Requires-Python: <4.0,>=3.10
10
+ Requires-Dist: basedpyright<2.0.0,>=1.12.5
11
+ Requires-Dist: json-with-comments<2.0.0,>=1.2.9
12
+ Requires-Dist: ruff>=0.0.291
13
+ Requires-Dist: toml<1.0.0,>=0.10.2
19
14
  Description-Content-Type: text/markdown
20
15
 
21
16
  ![pypi](https://github.com/dertilo/python-linters/actions/workflows/release.yml/badge.svg)
22
17
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
23
18
  [![bear-ified](https://raw.githubusercontent.com/beartype/beartype-assets/main/badge/bear-ified.svg)](https://beartype.readthedocs.io)
24
19
  # python-linters
25
- - bundles ruff and basedpyright into a single poetry-script
26
- - project independent linter configuration (via `ruff.toml`,`.flake8`) -> one config to rule them all
20
+ - bundles ruff and ~~flake8~~ basedpyright into a single ~~poetry~~uv-script
21
+ - even though I liked some flake8-rules (especially from [wemake-python-styleguide](https://wemake-python-styleguide.readthedocs.io/en/latest/)) dropped it in favor of ruff for being too slow
22
+ - project independent linter configuration (via `ruff.toml`,~~`.flake8`~~`pyrightconfig.json`) -> one config to rule them all
23
+ - well one can still override the default config via `ruff_extensions.toml` and `pyrightconfig.json`
27
24
  ### use-cases:
28
- 1. interactively learning python code quality standards via ruff+flake8, see [local development workflow](#2-local-development-workflow-before-pushing-to-ci-pipeline)
25
+ 1. interactively learning python code quality standards via ruff+pyright, see [local development workflow](#2-local-development-workflow-before-pushing-to-ci-pipeline)
29
26
  2. enforcing minimal quality-standards via a "lint-stage" in a ci-pipeline, see [setup for ci-pipeline](#3-setup-for-ci-pipeline)
30
27
  ## 0. motivation:
31
28
  ### Python is a Bicycle!
@@ -73,13 +70,12 @@ python-linters = { version = "<some-version-here>" }
73
70
  ],
74
71
  ```
75
72
  ### three scripts/commands that you can run locally
76
- 1. `poetry run fixcode` to let black+isort+ruff "auto-fix" your code -> always have a `clean` git-repo before doing this (no uncommitted changes)
73
+ 1. `uv run fixcode` to let black+isort+ruff "auto-fix" your code -> always have a `clean` git-repo before doing this (no uncommitted changes)
77
74
  - [example output](#fixcode-example)
78
- 1. `poetry run pythonlinter` -> to lint your code
75
+ 1. `uv run pythonlinter` -> to lint your code
79
76
  - [example black is not happy](#pythonlinter-black-is-not-happy) -> if you ran `fixcode` black is guaranteed to be happy!
80
77
  - [example ruff is not happy](#pythonlinter-ruff-is-not-happy)
81
- - [example flake8 is not happy](#pythonlinter-flake8-is-not-happy)
82
- 1. `poetry run addnoqa` to let ruff insert rules-violation-comments to your code
78
+ 1. `uv run addnoqa` to let ruff insert rules-violation-comments to your code
83
79
  - [example](#addnoqa-example)
84
80
  ```mermaid
85
81
  flowchart TD
@@ -89,9 +85,9 @@ classDef style2 fill:#ffffba
89
85
  classDef style3 fill:#baffc9
90
86
  classDef style4 fill:#bae1ff
91
87
  op1["start: have a 'clean' repo"]:::style4 --> op2
92
- op2[\"poetry run fixcode\n refactor & git commit"/]:::style1 --> cond9{{"poetry run pythonlinter"}}:::style0
88
+ op2[\"uv run fixcode\n refactor & git commit"/]:::style1 --> cond9{{"uv run pythonlinter"}}:::style0
93
89
  cond9 --> | complains | cond47{{"ruff"}}:::style0
94
- cond47 --> | complains | op51[\"poetry run addnoqa"/]:::style1
90
+ cond47 --> | complains | op51[\"uv run addnoqa"/]:::style1
95
91
  op51 --> sub53[\"refactor your code \nOR\n keep/add noqa-comment"/]:::style1
96
92
  sub53 --> op2
97
93
  cond47 --> | is happy | cond58{{"pyright"}}:::style0
@@ -100,11 +96,11 @@ cond58 --> | is happy | sub66["git commit"]
100
96
  sub66 --> sub80
101
97
  cond9 --> | is happy | sub80["git push"]:::style3
102
98
  ```
103
- - write-operations (changing your code): `poetry run fixcode`, `poerty run addnoqa`, `refactor your code`
104
- - read-only-operations: `poetry run pythonlinter`,`git commit`, `git push`
99
+ - write-operations (changing your code): `uv run fixcode`, `poerty run addnoqa`, `refactor your code`
100
+ - read-only-operations: `uv run pythonlinter`,`git commit`, `git push`
105
101
 
106
102
  ## 3. setup for ci-pipeline
107
- * if you specified the packages in the `pyproject.toml` and you run just run `poetry run pythonlinter` without any arguments than the `pyproject.toml` is getting parsed and specified packages are getting linted
103
+ * if you specified the packages in the `pyproject.toml` and you run just run `uv run pythonlinter` without any arguments than the `pyproject.toml` is getting parsed and specified packages are getting linted
108
104
  ```yaml
109
105
  stages:
110
106
  - lint # lint-stage!
@@ -132,7 +128,7 @@ linting:
132
128
  ### fixcode example
133
129
  ```commandline
134
130
  cd <somehwere>/whisper-streaming
135
- poetry run fixcode
131
+ uv run fixcode
136
132
  Fixing <somehwere>/whisper-streaming/whisper_streaming/post_asr_preparations.py
137
133
  whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py:231:30: ARG005 Unused lambda argument: `x`
138
134
  whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py:234:5: RET503 Missing explicit `return` at the end of function able to return non-`None` value
@@ -154,8 +150,8 @@ folders_to_be_linted=['whisper_streaming', 'tests']
154
150
  - a missing return statement
155
151
  - missing type annotations
156
152
  ```commandline
157
- poetry run pythonlinter
158
- linter-order: black->ruff->flake8
153
+ uv run pythonlinter
154
+ linter-order: black->ruff->pyright
159
155
 
160
156
  ...
161
157
 
@@ -171,7 +167,7 @@ python_linters.run_linters.LinterException: 💩 ruff is not happy! 💩
171
167
  ### addnoqa example
172
168
  - only shows how many noqas it added (`3`) and how many files it left unchanged (`22`)
173
169
  ```commandline
174
- poetry run addnoqa
170
+ uv run addnoqa
175
171
  Added 3 noqa directives.
176
172
  All done! ✨ 🍰 ✨
177
173
  22 files would be left unchanged.
@@ -196,17 +192,17 @@ def foobar(x): # noqa: ANN001, ANN202
196
192
  {
197
193
  "label": "fixcode",
198
194
  "type": "shell",
199
- "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && poetry run fixcode"
195
+ "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && uv run fixcode"
200
196
  },
201
197
  {
202
198
  "label": "addnoqa",
203
199
  "type": "shell",
204
- "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && poetry run addnoqa"
200
+ "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && uv run addnoqa"
205
201
  },
206
202
  {
207
203
  "label": "pythonlinter",
208
204
  "type": "shell",
209
- "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && poetry run pythonlinter"
205
+ "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && uv run pythonlinter"
210
206
  }
211
207
  ]
212
208
  }
@@ -215,4 +211,4 @@ def foobar(x): # noqa: ANN001, ANN202
215
211
  ![pycharm_settings.png](pycharm_settings.png)
216
212
  ## alternatives
217
213
  - https://github.com/astral-sh/ruff-vscode
218
- - https://plugins.jetbrains.com/plugin/20574-ruff
214
+ - https://plugins.jetbrains.com/plugin/20574-ruff
@@ -2,10 +2,12 @@
2
2
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
3
3
  [![bear-ified](https://raw.githubusercontent.com/beartype/beartype-assets/main/badge/bear-ified.svg)](https://beartype.readthedocs.io)
4
4
  # python-linters
5
- - bundles ruff and basedpyright into a single poetry-script
6
- - project independent linter configuration (via `ruff.toml`,`.flake8`) -> one config to rule them all
5
+ - bundles ruff and ~~flake8~~ basedpyright into a single ~~poetry~~uv-script
6
+ - even though I liked some flake8-rules (especially from [wemake-python-styleguide](https://wemake-python-styleguide.readthedocs.io/en/latest/)) dropped it in favor of ruff for being too slow
7
+ - project independent linter configuration (via `ruff.toml`,~~`.flake8`~~`pyrightconfig.json`) -> one config to rule them all
8
+ - well one can still override the default config via `ruff_extensions.toml` and `pyrightconfig.json`
7
9
  ### use-cases:
8
- 1. interactively learning python code quality standards via ruff+flake8, see [local development workflow](#2-local-development-workflow-before-pushing-to-ci-pipeline)
10
+ 1. interactively learning python code quality standards via ruff+pyright, see [local development workflow](#2-local-development-workflow-before-pushing-to-ci-pipeline)
9
11
  2. enforcing minimal quality-standards via a "lint-stage" in a ci-pipeline, see [setup for ci-pipeline](#3-setup-for-ci-pipeline)
10
12
  ## 0. motivation:
11
13
  ### Python is a Bicycle!
@@ -53,13 +55,12 @@ python-linters = { version = "<some-version-here>" }
53
55
  ],
54
56
  ```
55
57
  ### three scripts/commands that you can run locally
56
- 1. `poetry run fixcode` to let black+isort+ruff "auto-fix" your code -> always have a `clean` git-repo before doing this (no uncommitted changes)
58
+ 1. `uv run fixcode` to let black+isort+ruff "auto-fix" your code -> always have a `clean` git-repo before doing this (no uncommitted changes)
57
59
  - [example output](#fixcode-example)
58
- 1. `poetry run pythonlinter` -> to lint your code
60
+ 1. `uv run pythonlinter` -> to lint your code
59
61
  - [example black is not happy](#pythonlinter-black-is-not-happy) -> if you ran `fixcode` black is guaranteed to be happy!
60
62
  - [example ruff is not happy](#pythonlinter-ruff-is-not-happy)
61
- - [example flake8 is not happy](#pythonlinter-flake8-is-not-happy)
62
- 1. `poetry run addnoqa` to let ruff insert rules-violation-comments to your code
63
+ 1. `uv run addnoqa` to let ruff insert rules-violation-comments to your code
63
64
  - [example](#addnoqa-example)
64
65
  ```mermaid
65
66
  flowchart TD
@@ -69,9 +70,9 @@ classDef style2 fill:#ffffba
69
70
  classDef style3 fill:#baffc9
70
71
  classDef style4 fill:#bae1ff
71
72
  op1["start: have a 'clean' repo"]:::style4 --> op2
72
- op2[\"poetry run fixcode\n refactor & git commit"/]:::style1 --> cond9{{"poetry run pythonlinter"}}:::style0
73
+ op2[\"uv run fixcode\n refactor & git commit"/]:::style1 --> cond9{{"uv run pythonlinter"}}:::style0
73
74
  cond9 --> | complains | cond47{{"ruff"}}:::style0
74
- cond47 --> | complains | op51[\"poetry run addnoqa"/]:::style1
75
+ cond47 --> | complains | op51[\"uv run addnoqa"/]:::style1
75
76
  op51 --> sub53[\"refactor your code \nOR\n keep/add noqa-comment"/]:::style1
76
77
  sub53 --> op2
77
78
  cond47 --> | is happy | cond58{{"pyright"}}:::style0
@@ -80,11 +81,11 @@ cond58 --> | is happy | sub66["git commit"]
80
81
  sub66 --> sub80
81
82
  cond9 --> | is happy | sub80["git push"]:::style3
82
83
  ```
83
- - write-operations (changing your code): `poetry run fixcode`, `poerty run addnoqa`, `refactor your code`
84
- - read-only-operations: `poetry run pythonlinter`,`git commit`, `git push`
84
+ - write-operations (changing your code): `uv run fixcode`, `poerty run addnoqa`, `refactor your code`
85
+ - read-only-operations: `uv run pythonlinter`,`git commit`, `git push`
85
86
 
86
87
  ## 3. setup for ci-pipeline
87
- * if you specified the packages in the `pyproject.toml` and you run just run `poetry run pythonlinter` without any arguments than the `pyproject.toml` is getting parsed and specified packages are getting linted
88
+ * if you specified the packages in the `pyproject.toml` and you run just run `uv run pythonlinter` without any arguments than the `pyproject.toml` is getting parsed and specified packages are getting linted
88
89
  ```yaml
89
90
  stages:
90
91
  - lint # lint-stage!
@@ -112,7 +113,7 @@ linting:
112
113
  ### fixcode example
113
114
  ```commandline
114
115
  cd <somehwere>/whisper-streaming
115
- poetry run fixcode
116
+ uv run fixcode
116
117
  Fixing <somehwere>/whisper-streaming/whisper_streaming/post_asr_preparations.py
117
118
  whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py:231:30: ARG005 Unused lambda argument: `x`
118
119
  whisper_streaming/faster_whisper_inference/faster_whisper_inferencer.py:234:5: RET503 Missing explicit `return` at the end of function able to return non-`None` value
@@ -134,8 +135,8 @@ folders_to_be_linted=['whisper_streaming', 'tests']
134
135
  - a missing return statement
135
136
  - missing type annotations
136
137
  ```commandline
137
- poetry run pythonlinter
138
- linter-order: black->ruff->flake8
138
+ uv run pythonlinter
139
+ linter-order: black->ruff->pyright
139
140
 
140
141
  ...
141
142
 
@@ -151,7 +152,7 @@ python_linters.run_linters.LinterException: 💩 ruff is not happy! 💩
151
152
  ### addnoqa example
152
153
  - only shows how many noqas it added (`3`) and how many files it left unchanged (`22`)
153
154
  ```commandline
154
- poetry run addnoqa
155
+ uv run addnoqa
155
156
  Added 3 noqa directives.
156
157
  All done! ✨ 🍰 ✨
157
158
  22 files would be left unchanged.
@@ -176,17 +177,17 @@ def foobar(x): # noqa: ANN001, ANN202
176
177
  {
177
178
  "label": "fixcode",
178
179
  "type": "shell",
179
- "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && poetry run fixcode"
180
+ "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && uv run fixcode"
180
181
  },
181
182
  {
182
183
  "label": "addnoqa",
183
184
  "type": "shell",
184
- "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && poetry run addnoqa"
185
+ "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && uv run addnoqa"
185
186
  },
186
187
  {
187
188
  "label": "pythonlinter",
188
189
  "type": "shell",
189
- "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && poetry run pythonlinter"
190
+ "command": "cd $(cd ${fileDirname} && git rev-parse --show-toplevel) && uv run pythonlinter"
190
191
  }
191
192
  ]
192
193
  }
@@ -0,0 +1,40 @@
1
+ [project]
2
+ name = "python-linters"
3
+ description = "bundling config files for linters like ruff and pyright"
4
+ authors = [ { name = "Tilo Himmelsbach", email = "dertilo@gmail.com" } ]
5
+ readme = "README.md"
6
+ license = {text = "MIT"}
7
+ requires-python = "<4.0,>=3.10"
8
+ dependencies = [
9
+ "toml<1.0.0,>=0.10.2",
10
+ "ruff>=0.0.291",
11
+ "basedpyright<2.0.0,>=1.12.5",
12
+ "json-with-comments<2.0.0,>=1.2.9",
13
+ ]
14
+ dynamic = [
15
+ "version"
16
+ ]
17
+
18
+ [project.urls]
19
+ repository = "https://github.com/dertilo/python-linters"
20
+
21
+ [project.scripts]
22
+ pythonlinter = "python_linters.run_linters:main"
23
+ fixcode = "python_linters.fix_code:main"
24
+ addnoqa = "python_linters.add_noqa:main"
25
+
26
+ [build-system]
27
+ requires = ["hatchling", "hatch-vcs"]
28
+ build-backend = "hatchling.build"
29
+
30
+ [tool.hatch.version]
31
+ source = "vcs"
32
+
33
+ [tool.hatch.build.hooks.vcs]
34
+ version-file = "_version.py"
35
+
36
+ [tool.hatch.build.targets.sdist]
37
+ packages = ["python_linters"] # packages option is semantically equivalent to only-include
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["python_linters"]
@@ -2,28 +2,30 @@ import os
2
2
 
3
3
  from python_linters.extending_ruff_toml import create_extended_ruff_toml
4
4
  from python_linters.getting_to_be_linted_folders import get_folders_to_be_linted
5
- from python_linters.run_linters import run_cmd
5
+ from python_linters.utils import run_cmd, get_pyproject_dir
6
6
 
7
7
 
8
8
  def main() -> None:
9
9
  """
10
10
  expects to run from $ContentRoot$
11
11
  """
12
- folders_tobelinted = get_folders_to_be_linted("pyproject.toml")
12
+ dirr = get_pyproject_dir()
13
+ folders_tobelinted = get_folders_to_be_linted(f"{dirr}/pyproject.toml")
14
+
13
15
  BIG_NUMBER = 9
14
16
  for k in range(
15
17
  BIG_NUMBER,
16
18
  ): # theoretically could be necessary to run this loop as long as code changes!
17
19
  print(f"addnoqa iteration: {k}")
18
20
  run_cmd(
19
- f"ruff check {' '.join(folders_tobelinted)} --config={create_extended_ruff_toml()} --add-noqa",
21
+ f"cd {dirr} && ruff check {' '.join(folders_tobelinted)} --config={create_extended_ruff_toml(str(dirr))} --add-noqa",
20
22
  )
21
23
  try:
22
- run_cmd(f"ruff format --check {' '.join(folders_tobelinted)}")
24
+ run_cmd(f"cd {dirr} && ruff format --check {' '.join(folders_tobelinted)}")
23
25
  break
24
26
  except Exception:
25
- run_cmd(f"ruff format {' '.join(folders_tobelinted)}")
26
- run_cmd(f"fixcode {os.getcwd()}")
27
+ run_cmd(f"cd {dirr} && ruff format {' '.join(folders_tobelinted)}")
28
+ run_cmd(f"fixcode {dirr}")
27
29
 
28
30
 
29
31
  if __name__ == "__main__":
@@ -2,10 +2,8 @@ import pathlib
2
2
 
3
3
  package_dir = str(pathlib.Path(__file__).parent.resolve())
4
4
 
5
- FLAKE8_CONFIG_FILE = f"{package_dir}/.flake8"
6
5
  RUFF_CONFIG_FILE = f"{package_dir}/ruff.toml"
7
6
  PYRIGHT_CONFIG_FILE = f"{package_dir}/pyrightconfig.json"
8
7
 
9
- assert pathlib.Path(FLAKE8_CONFIG_FILE).is_file()
10
8
  assert pathlib.Path(RUFF_CONFIG_FILE).is_file()
11
9
  assert pathlib.Path(PYRIGHT_CONFIG_FILE).is_file()
@@ -4,17 +4,22 @@ from pathlib import Path
4
4
  from python_linters.config_files import RUFF_CONFIG_FILE
5
5
 
6
6
 
7
- def create_extended_ruff_toml() -> str:
8
- ruff_extension_file = Path("ruff_extension.toml")
7
+ def create_extended_ruff_toml(package_root:str) -> str:
8
+ ruff_extension_file = Path(f"{package_root}/ruff_extension.toml")
9
+ ruff_toml_file = Path(f"{package_root}/ruff.toml")
10
+ if ruff_toml_file.is_file():
11
+ ruff_config_file = str(ruff_toml_file)
12
+ else:
13
+ ruff_config_file = RUFF_CONFIG_FILE
9
14
 
15
+ print(f"using {ruff_config_file=}")
10
16
  if ruff_extension_file.is_file():
11
- fingerprint = f"{ruff_extension_file.stat().st_size}-{ruff_extension_file.stat().st_mtime}"
12
- extended_ruff_toml_file = f"extended_ruff-{fingerprint}.toml"
17
+ extended_ruff_toml_file = f"{package_root}/extended_ruff.toml"
13
18
  if not Path(extended_ruff_toml_file).is_file():
14
- print(f"extending {RUFF_CONFIG_FILE} with {ruff_extension_file=}")
19
+ print(f"extending {ruff_config_file} with {ruff_extension_file=}")
15
20
  with Path(extended_ruff_toml_file).open("w", encoding="locale") as f:
16
21
  lines = [
17
- f'extend = "{RUFF_CONFIG_FILE}"',
22
+ f'extend = "{ruff_config_file}"',
18
23
  *list(_read_lines(ruff_extension_file)),
19
24
  ]
20
25
  for l in lines:
@@ -22,7 +27,7 @@ def create_extended_ruff_toml() -> str:
22
27
  else:
23
28
  print(f"using {extended_ruff_toml_file}")
24
29
  else:
25
- extended_ruff_toml_file = RUFF_CONFIG_FILE
30
+ extended_ruff_toml_file = ruff_config_file
26
31
  return extended_ruff_toml_file
27
32
 
28
33
 
@@ -0,0 +1,25 @@
1
+ from python_linters.extending_ruff_toml import create_extended_ruff_toml
2
+ from python_linters.getting_to_be_linted_folders import get_folders_to_be_linted
3
+
4
+ from python_linters.utils import run_cmd_ignore_errors, run_cmd, \
5
+ get_pyproject_dir
6
+
7
+
8
+ def main() -> None:
9
+ """
10
+ $FilePath$ in pycharm
11
+ """
12
+ dirr = get_pyproject_dir()
13
+ folders_to_be_linted = get_folders_to_be_linted(f"{dirr}/pyproject.toml")
14
+ folders = " ".join(folders_to_be_linted)
15
+ extended_ruff_toml = create_extended_ruff_toml(str(dirr))
16
+ run_cmd_ignore_errors(
17
+ f"cd {dirr} && ruff check {folders} --config={extended_ruff_toml} --fix",
18
+ )
19
+ run_cmd(f"cd {dirr} && ruff format {folders} --config={extended_ruff_toml}")
20
+
21
+
22
+
23
+
24
+ if __name__ == "__main__":
25
+ main()
@@ -35,17 +35,8 @@ def get_folders_to_be_linted(pyproject_toml: str) -> list[str]:
35
35
  .get("python-linters", {})
36
36
  .get("folders_to_be_linted", None)
37
37
  )
38
- if (
39
- folders is None
40
- and (packages := t.get("tool", {}).get("poetry", {}).get("packages", None))
41
- is not None
42
- ):
43
- folders = [p["include"] for p in packages]
44
- if pathlib.Path(f"{pathlib.Path(pyproject_toml).parent}/tests").is_dir():
45
- folders += ["tests"]
46
-
47
38
  if folders is None:
48
- raise PackagesOrFoldersToBeLintedAreNotProperlyDefined
49
- assert len(folders) > 0
39
+ folders = ["./"]
40
+ # raise PackagesOrFoldersToBeLintedAreNotProperlyDefined
50
41
  print(f"found following {folders=}")
51
42
  return folders
@@ -17,5 +17,9 @@
17
17
  "reportUnknownArgumentType": "warning",
18
18
  "reportMissingTypeArgument": "warning",
19
19
  "reportUnknownParameterType": "warning",
20
- "reportUnusedVariable": "warning"
20
+ "reportUnusedVariable": "warning",
21
+ "exclude": [
22
+ "**/___*",
23
+ "tests"
24
+ ]
21
25
  }