Merge branch 'feat/generalize-linter-format' into main

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
nvaldez
2026-09-28 20:01:06 +02:00
5 changed files with 25 additions and 21 deletions
+9 -8
View File
@@ -663,10 +663,10 @@ the next free section number.
> Status: Implemented
>
> Covers: `src/mdoctor/`. Wraps the pymarkdown linter over markdown
> sources with an AI-friendly aggregated violation report (file,
> line:column, rule). Also provides `mdoctor list [directory]`, which
> lists all files (not only md) in a directory via the librarian
> (see 4.8).
> sources with an AI-friendly aggregated violation report in the shared
> linter format (file, line:column, rule; see [4.9.3](#493-linter-report-format)).
> Also provides `mdoctor list [directory]`, which lists all files (not
> only md) in a directory via the librarian (see 4.8).
#### 4.1.1. MDoctor Auto-Fix (`mdoctor fix`)
@@ -1092,13 +1092,14 @@ shared functionality.
> Status: Implemented
>
> Covers: `src/python_ruff/`. Wraps the external `ruff` linter over
> Python sources, mirroring the mdoctor report pattern.
> Python sources with an AI-friendly aggregated violation report in the
> shared linter format (see [4.9.3](#493-linter-report-format)).
- *4.5.1.* Violations report file, line:column, and rule code in an
AI-friendly aggregated report.
AI-friendly aggregated report using the shared linter format [4.9.3](#493-linter-report-format).
- *acceptance*: A file with a lint violation (e.g. an unused import) is
reported
with file, position, and rule code.
reported with file, position, and rule code in DEFINITIONS, FILE, and
SUMMARY sections.
- *4.5.2.* Integrated into the sanity runner [4.9](#49-test-and-sanity-runners).
- *4.5.3.* The library supports auto-fix: `PythonRuff.lint(target, fix=True)`
passes `--fix` through to the ruff binary and modifies files in place.
+1 -1
View File
@@ -105,7 +105,7 @@ class InlineImportVisitor(ast.NodeVisitor):
line=node.lineno,
column=node.col_offset,
code="PYC001",
message=f"Inline import: {import_stmt}",
message=f"PYC001 Inline import: {import_stmt}",
rule_id="inline-import"
)
self.violations.append(violation)
+3 -3
View File
@@ -402,9 +402,9 @@ def run_pycustomlint():
# Lint all Python files in src directory
violations = linter.lint_directory("src")
formated_violations = linter.format_violations_report(
violations, target="src", linter_name="Python Custom Lint"
)
# Use compressed format for consistency with other linters
compressed_violations = linter.compress_violations(violations, "src")
formated_violations = linter.format_compressed_violations(compressed_violations)
return {
"result": 0 if not violations else 1,
+8 -5
View File
@@ -411,8 +411,9 @@ def mock_python_custom_linter():
real_linter = PythonCustomLinter()
with patch("run_sanity.PythonCustomLinter") as linter_class:
instance = linter_class.return_value
instance.format_violations_report.side_effect = (
real_linter.format_violations_report
instance.compress_violations.side_effect = real_linter.compress_violations
instance.format_compressed_violations.side_effect = (
real_linter.format_compressed_violations
)
yield linter_class
@@ -429,18 +430,20 @@ class TestRunPycustomlint:
"""
filename = str(run_sanity.SETTINGS_FILE.parent / "customlinter" / "pycustomlint.py")
mock_python_custom_linter.return_value.lint_directory.return_value = [
_make_pyc_violation(filename, line=205, column=4, code="PYC001"),
_make_pyc_violation(filename, line=205, column=4, code="PYC001",
message="PYC001 Inline import: import argparse"),
]
result = run_sanity.run_pycustomlint()
assert result["result"] == 1
assert result["violation_count"] == 1
stdout = result["stdout"]
assert "Python Custom Lint Violations" in stdout
assert "TARGET: src" in stdout
assert "TARGET:" in stdout and "src" in stdout
assert "- DEFINITIONS:" in stdout
assert "- PYC001: Inline Import, Import statement found inside function" \
" or block (inline import)" in stdout
assert f"- FILE: {filename}" in stdout
# File path is relative to target (src)
assert "- FILE: customlinter/pycustomlint.py" in stdout
assert " - PYC001 Inline import: import argparse" in stdout
assert "- SUMMARY:" in stdout
# file count first, matching the fmlint and markdownlint reports
+4 -4
View File
@@ -120,18 +120,18 @@ block a correct install or make the docs contradict the code.
- [x] Add CLI integration: `fiona-assistant fmlint chklint [directory]`
- [x] Integrate into `run_sanity.py`
- [x] Add settings support via `fiona-settings.json`
- [ ] Generalize compress and format violations for all linters
- [x] Generalize compress and format violations for all linters
(SPEC 4.3.1, 4.9.3)
- [x] `BaseLinter` provides `compress_violations()` and
`format_compressed_violations()`; report header comes from the
`linter_name` class attribute
- [x] `fmlint` delegates `format_violations` and `lint_directory`
compression to the shared base methods (output unchanged)
- [ ] Migrate `mdoctor` (`compress_violations`/`format_violations`,
- [x] Migrate `mdoctor` (`compress_violations`/`format_violations`,
same compressed shape as fmlint) onto the shared base format
- [ ] Migrate `python_ruff` (different compressed shape:
- [x] Migrate `python_ruff` (different compressed shape:
`dict[rel_path, list[dict]]`) onto the shared base format
- [ ] Keep all linter reports diffable: same sections, same order
- [x] Keep all linter reports diffable: same sections, same order
(update SPEC 4.1/4.5 and tests together)
- [ ] JSON linter (json-lint) (SPEC 4.10)
- [ ] Implement `src/json_lint/json_lint.py` module