konform 0.1.0__py3-none-win_amd64.whl
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.
|
Binary file
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: konform
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Python
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Classifier: Programming Language :: Rust
|
|
11
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Summary: Multi-rule Python linter and language server — fast, configurable, CI-ready
|
|
14
|
+
Keywords: konform,python,linter,imports,language-server
|
|
15
|
+
Home-Page: https://github.com/benediktziegler/konform
|
|
16
|
+
Author-email: Benedikt Ziegler <benediktziegler@gmail.com>
|
|
17
|
+
License: MIT
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
20
|
+
Project-URL: Bug Tracker, https://github.com/benediktziegler/konform/issues
|
|
21
|
+
Project-URL: Homepage, https://github.com/benediktziegler/konform
|
|
22
|
+
Project-URL: Source, https://github.com/benediktziegler/konform
|
|
23
|
+
|
|
24
|
+
# konform
|
|
25
|
+
|
|
26
|
+
Multi-rule Python linter and language server — fast, configurable, and CI-ready.
|
|
27
|
+
|
|
28
|
+
## Rules
|
|
29
|
+
|
|
30
|
+
### KIS001 — Google-style imports
|
|
31
|
+
|
|
32
|
+
Checks that every `from X import Y` only imports a sub-module, not an object
|
|
33
|
+
(function, class, or constant), following the
|
|
34
|
+
[Google Python Style Guide §2.2](https://google.github.io/styleguide/pyguide.html#22-imports).
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
# Bad — KIS001: `join` is a function, not a module
|
|
38
|
+
from os.path import join
|
|
39
|
+
|
|
40
|
+
# Good
|
|
41
|
+
import os.path
|
|
42
|
+
from os import path # `path` is a module
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### KPT — User-defined pattern rules
|
|
46
|
+
|
|
47
|
+
Load regex patterns from `konform_patterns.toml` (auto-discovered next to
|
|
48
|
+
`pyproject.toml`) or inline in `pyproject.toml`:
|
|
49
|
+
|
|
50
|
+
```toml
|
|
51
|
+
[[tool.konform.KPT.rules]]
|
|
52
|
+
id = "KPT001"
|
|
53
|
+
message = "Use the project logger instead of bare print()."
|
|
54
|
+
pattern = '^\s*print\s*\('
|
|
55
|
+
files = ["src/**/*.py"]
|
|
56
|
+
level = "warning"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install konform
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Wheels ship a pre-compiled Rust binary — no Rust installation needed at runtime.
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Lint all Python files under src/
|
|
71
|
+
konform check src/
|
|
72
|
+
|
|
73
|
+
# Lint and apply auto-fixes in one pass
|
|
74
|
+
konform check --fix src/
|
|
75
|
+
|
|
76
|
+
# Apply fixes only (no lint report)
|
|
77
|
+
konform check --fix src/
|
|
78
|
+
|
|
79
|
+
# Show a unified diff of what format would change
|
|
80
|
+
konform check --diff src/
|
|
81
|
+
|
|
82
|
+
# Output violations as JSON (e.g. for tooling)
|
|
83
|
+
konform check --output-format json src/
|
|
84
|
+
|
|
85
|
+
# Suppress hints and summary (violations only)
|
|
86
|
+
konform check -q src/
|
|
87
|
+
|
|
88
|
+
# No output — just exit 1 on violations
|
|
89
|
+
konform check -s src/
|
|
90
|
+
|
|
91
|
+
# List all rules
|
|
92
|
+
konform rule --list
|
|
93
|
+
|
|
94
|
+
# Explain a rule
|
|
95
|
+
konform rule --explain KIS001
|
|
96
|
+
|
|
97
|
+
# Clear the local cache
|
|
98
|
+
konform clean
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Configuration
|
|
102
|
+
|
|
103
|
+
Add a `[tool.konform]` section to `pyproject.toml` (or a standalone `konform.toml`):
|
|
104
|
+
|
|
105
|
+
```toml
|
|
106
|
+
[tool.konform]
|
|
107
|
+
select = [] # [] = all rules; prefix match: "KIS" = all KIS* rules
|
|
108
|
+
ignore = []
|
|
109
|
+
level = "error" # "warning" | "error"
|
|
110
|
+
cache_dir = ".konform_cache"
|
|
111
|
+
workers = 0 # 0 = os.cpu_count()
|
|
112
|
+
|
|
113
|
+
# ── KIS — import style ────────────────────────────────────────────────────
|
|
114
|
+
[tool.konform.KIS]
|
|
115
|
+
exceptions = [
|
|
116
|
+
"__future__", "typing", "typing_extensions", "collections.abc",
|
|
117
|
+
"mycompany.compat",
|
|
118
|
+
]
|
|
119
|
+
level = "error"
|
|
120
|
+
unresolved_level = "warning" # "warning" (default) | "error" | "off"
|
|
121
|
+
# Used when a package isn't installed in this
|
|
122
|
+
# environment, so KIS001 can't tell whether the
|
|
123
|
+
# imported name is a module or not.
|
|
124
|
+
|
|
125
|
+
# ── KPT — user-defined patterns ───────────────────────────────────────────
|
|
126
|
+
[tool.konform.KPT]
|
|
127
|
+
level = "warning"
|
|
128
|
+
# Optional: load patterns from an external file instead of inline rules.
|
|
129
|
+
# rules_file = "konform_patterns.toml"
|
|
130
|
+
|
|
131
|
+
[[tool.konform.KPT.rules]]
|
|
132
|
+
id = "KPT001"
|
|
133
|
+
message = "Use the project logger instead of bare print()."
|
|
134
|
+
pattern = '^\s*print\s*\('
|
|
135
|
+
files = ["src/**/*.py"]
|
|
136
|
+
level = "warning"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Pattern files
|
|
140
|
+
|
|
141
|
+
Patterns can also live in a standalone `konform_patterns.toml` placed next to
|
|
142
|
+
`pyproject.toml`. konform auto-discovers it (no config key needed):
|
|
143
|
+
|
|
144
|
+
```toml
|
|
145
|
+
# konform_patterns.toml
|
|
146
|
+
[[rules]]
|
|
147
|
+
id = "KPT002"
|
|
148
|
+
message = "Remove breakpoint() — debugging artefact."
|
|
149
|
+
pattern = '^\s*breakpoint\s*\(\s*\)'
|
|
150
|
+
level = "error"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Suppressing violations
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from os.path import join # noqa: KIS001 ← exact rule
|
|
157
|
+
from os.path import join # noqa: KIS ← whole category
|
|
158
|
+
from os.path import join # noqa ← everything on this line
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Aliasing noqa codes
|
|
162
|
+
|
|
163
|
+
When a rule code changes (e.g. a rule is renamed, or a project migrates
|
|
164
|
+
from another linter's codes), old `# noqa` comments would otherwise stop
|
|
165
|
+
working. Define aliases in your config so they keep suppressing the
|
|
166
|
+
renamed/canonical rule:
|
|
167
|
+
|
|
168
|
+
```toml
|
|
169
|
+
# pyproject.toml
|
|
170
|
+
[tool.konform.noqa_aliases]
|
|
171
|
+
IS001 = "KIS001"
|
|
172
|
+
IS = "KIS"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from os.path import join # noqa: IS001 ← suppresses KIS001 via alias
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Language Server (LSP)
|
|
180
|
+
|
|
181
|
+
konform ships a built-in LSP server that shares the same rule engine as the
|
|
182
|
+
CLI — no second process, no stale results.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
konform server # starts the LSP over stdin/stdout
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Neovim (nvim-lspconfig)
|
|
189
|
+
|
|
190
|
+
```lua
|
|
191
|
+
vim.api.nvim_create_autocmd("FileType", {
|
|
192
|
+
pattern = "python",
|
|
193
|
+
callback = function()
|
|
194
|
+
vim.lsp.start({
|
|
195
|
+
name = "konform",
|
|
196
|
+
cmd = { "konform", "server" },
|
|
197
|
+
root_dir = vim.fs.dirname(
|
|
198
|
+
vim.fs.find({ "pyproject.toml", "konform.toml" }, { upward = true })[1]
|
|
199
|
+
),
|
|
200
|
+
})
|
|
201
|
+
end,
|
|
202
|
+
})
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### VS Code (`settings.json`)
|
|
206
|
+
|
|
207
|
+
Add via the generic
|
|
208
|
+
[`None ls`](https://marketplace.visualstudio.com/items?itemName=esbenp.none-ls-vscode)
|
|
209
|
+
or any client that supports a custom LSP command:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"nls.server": {
|
|
214
|
+
"command": ["konform", "server"]
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Zed
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"lsp": {
|
|
224
|
+
"konform": {
|
|
225
|
+
"binary": {
|
|
226
|
+
"path": "konform",
|
|
227
|
+
"arguments": ["server"]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Development
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Compile the Rust binary and install it in the dev venv (required before tests)
|
|
238
|
+
hatch run develop
|
|
239
|
+
|
|
240
|
+
# Run tests with coverage
|
|
241
|
+
hatch test -c
|
|
242
|
+
|
|
243
|
+
# Build release wheels for all platforms
|
|
244
|
+
hatch run maturin:build-all
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## CLI reference
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
konform check [OPTIONS] <PATHS>… Lint files (default subcommand)
|
|
251
|
+
konform check --fix-only [OPTIONS] <PATHS>… Apply all auto-fixes in-place, exit 0
|
|
252
|
+
konform server Start the LSP server (stdin/stdout)
|
|
253
|
+
konform rule --list List all rules
|
|
254
|
+
konform rule --explain <CODE> Show full rule documentation
|
|
255
|
+
konform clean [--config PATH] Delete the cache directory
|
|
256
|
+
konform version Print konform's version
|
|
257
|
+
|
|
258
|
+
Global options (available on all subcommands):
|
|
259
|
+
--color auto|always|never Colour output control
|
|
260
|
+
--isolated Ignore all config files
|
|
261
|
+
-v / --verbose Extra output
|
|
262
|
+
-q / --quiet Violations only (no summary/hints)
|
|
263
|
+
-s / --silent No output; exit code only
|
|
264
|
+
```
|
|
265
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
konform-0.1.0.data/scripts/konform.exe,sha256=795KpXaJohYKC4d4ugTIctMIDEZ-N0ZhGv4z3eoJZso,7414784
|
|
2
|
+
konform-0.1.0.dist-info/METADATA,sha256=RrmLvNAttvAnDiAOZY5EcMcXw0w-x4prp4WCRRTDFpk,7498
|
|
3
|
+
konform-0.1.0.dist-info/WHEEL,sha256=8Aej0W0a6Cz6apA3IzJrTnxLRVLAt-w0Oh8SA3Con_c,94
|
|
4
|
+
konform-0.1.0.dist-info/licenses/LICENSE,sha256=JTqvz-BECEbtxIvxL56QkuZXnV1daKGXip_Xcb2vPnQ,1094
|
|
5
|
+
konform-0.1.0.dist-info/sboms/konform.cyclonedx.json,sha256=R7a1xYOZyziejBvZAJvukAJvHr_5FrrbfVEbUUpQjaU,183091
|
|
6
|
+
konform-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Benedikt Ziegler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|