python-code-quality 0.1.9__tar.gz → 0.1.10__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 (65) hide show
  1. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/PKG-INFO +39 -6
  2. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/README.md +33 -0
  3. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/pyproject.toml +5 -5
  4. python_code_quality-0.1.9/.gitea/workflows/python-multi-version-test.yaml +0 -65
  5. python_code_quality-0.1.9/.gitea/workflows/test.yaml +0 -11
  6. python_code_quality-0.1.9/.github/workflows/python-publish.yml +0 -70
  7. python_code_quality-0.1.9/.gitignore +0 -18
  8. python_code_quality-0.1.9/.python-version +0 -1
  9. python_code_quality-0.1.9/CLAUDE.md +0 -54
  10. python_code_quality-0.1.9/LICENSE +0 -21
  11. python_code_quality-0.1.9/tests/conftest.py +0 -7
  12. python_code_quality-0.1.9/tests/test_cli.py +0 -361
  13. python_code_quality-0.1.9/tests/test_common.py +0 -119
  14. python_code_quality-0.1.9/tests/test_config.py +0 -84
  15. python_code_quality-0.1.9/tests/test_context_hash.py +0 -81
  16. python_code_quality-0.1.9/tests/test_execution_engine.py +0 -293
  17. python_code_quality-0.1.9/tests/test_integration_user_tools.py +0 -152
  18. python_code_quality-0.1.9/tests/test_language_detector.py +0 -87
  19. python_code_quality-0.1.9/tests/test_llm_formatter.py +0 -237
  20. python_code_quality-0.1.9/tests/test_localtypes.py +0 -102
  21. python_code_quality-0.1.9/tests/test_parser_bandit.py +0 -66
  22. python_code_quality-0.1.9/tests/test_parser_compile.py +0 -61
  23. python_code_quality-0.1.9/tests/test_parser_complexity.py +0 -76
  24. python_code_quality-0.1.9/tests/test_parser_coverage.py +0 -59
  25. python_code_quality-0.1.9/tests/test_parser_exitcode.py +0 -39
  26. python_code_quality-0.1.9/tests/test_parser_halstead.py +0 -116
  27. python_code_quality-0.1.9/tests/test_parser_interrogate.py +0 -72
  28. python_code_quality-0.1.9/tests/test_parser_linecount.py +0 -42
  29. python_code_quality-0.1.9/tests/test_parser_maintainability.py +0 -74
  30. python_code_quality-0.1.9/tests/test_parser_pytest.py +0 -112
  31. python_code_quality-0.1.9/tests/test_parser_regexcount.py +0 -42
  32. python_code_quality-0.1.9/tests/test_parser_ruff.py +0 -33
  33. python_code_quality-0.1.9/tests/test_parser_ty.py +0 -33
  34. python_code_quality-0.1.9/tests/test_parser_vulture.py +0 -51
  35. python_code_quality-0.1.9/tests/test_tool_registry.py +0 -16
  36. python_code_quality-0.1.9/uv.lock +0 -519
  37. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/__init__.py +0 -0
  38. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/cli.py +0 -0
  39. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/config/__init__.py +0 -0
  40. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/config/config.yaml +0 -0
  41. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/context_hash.py +0 -0
  42. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/execution_engine.py +0 -0
  43. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/language_detector.py +0 -0
  44. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/llm_formatter.py +0 -0
  45. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/localtypes.py +0 -0
  46. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/main.py +0 -0
  47. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/metric_aggregator.py +0 -0
  48. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/__init__.py +0 -0
  49. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/banditparser.py +0 -0
  50. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/common.py +0 -0
  51. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/compileparser.py +0 -0
  52. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/complexityparser.py +0 -0
  53. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/coverageparser.py +0 -0
  54. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/exitcodeparser.py +0 -0
  55. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/halsteadparser.py +0 -0
  56. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/interrogateparser.py +0 -0
  57. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/linecountparser.py +0 -0
  58. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/maintainabilityparser.py +0 -0
  59. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/pytestparser.py +0 -0
  60. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/regexcountparser.py +0 -0
  61. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/ruffparser.py +0 -0
  62. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/typarser.py +0 -0
  63. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/parsers/vultureparser.py +0 -0
  64. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/py.typed +0 -0
  65. {python_code_quality-0.1.9 → python_code_quality-0.1.10}/src/py_cq/tool_registry.py +0 -0
@@ -1,20 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-code-quality
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Python Code Quality Analysis Tool - feed the results from 11 CQ tools straight into an LLM. Minimal tokens.
5
- Project-URL: Homepage, https://github.com/rhiza-fr/py-cq
6
- Project-URL: Repository, https://github.com/rhiza-fr/py-cq
5
+ Author: Chris Kilner
7
6
  Author-email: Chris Kilner <chris@rhiza.fr>
8
7
  License-Expression: MIT
9
- License-File: LICENSE
10
- Requires-Python: >=3.12
11
8
  Requires-Dist: bandit>=1.8.0
12
9
  Requires-Dist: coverage>=7.8.2
13
10
  Requires-Dist: diskcache>=5.6.3
14
11
  Requires-Dist: interrogate>=1.7.0
12
+ Requires-Dist: pytest>=8.4.0
15
13
  Requires-Dist: pytest-cov>=6.1.1
16
14
  Requires-Dist: pytest-json-report>=1.5.0
17
- Requires-Dist: pytest>=8.4.0
18
15
  Requires-Dist: pyyaml>=6.0.2
19
16
  Requires-Dist: radon>=6.0.1
20
17
  Requires-Dist: rich>=14.0.0
@@ -22,6 +19,9 @@ Requires-Dist: ruff>=0.14.1
22
19
  Requires-Dist: ty>=0.0.17
23
20
  Requires-Dist: typer>=0.16.0
24
21
  Requires-Dist: vulture>=2.14
22
+ Requires-Python: >=3.12
23
+ Project-URL: Homepage, https://github.com/rhiza-fr/py-cq
24
+ Project-URL: Repository, https://github.com/rhiza-fr/py-cq
25
25
  Description-Content-Type: text/markdown
26
26
 
27
27
  # CQ - Python Code Quality Analysis Tool
@@ -115,6 +115,39 @@ cq check . && deploy # block deploy on errors
115
115
  cq check . -o score # print score, exit 1 on errors
116
116
  ```
117
117
 
118
+ ## Claude Code Integration
119
+
120
+ Add a stop hook to your project's `.claude/settings.json` so Claude automatically checks quality after each session and loops until clean:
121
+
122
+ ```json
123
+ {
124
+ "hooks": {
125
+ "Stop": [{
126
+ "matcher": "",
127
+ "hooks": [{"type": "command", "command": "cq check . -o score && echo 'CQ: all clear' || cq check . -o llm"}]
128
+ }]
129
+ }
130
+ }
131
+ ```
132
+
133
+ When the score passes, Claude sees `CQ: all clear` (~5 tokens). When it fails, Claude receives the targeted fix prompt and continues working. This automates the `cq check . -o llm | claude -p "fix this"` loop.
134
+
135
+ > **Note:** Use project-level `.claude/settings.json`, not global settings — this hook only makes sense in Python projects.
136
+
137
+ ### As a slash command (skill)
138
+
139
+ For manual invocation, create `.claude/commands/cq-fix.md`:
140
+
141
+ ```markdown
142
+ $(cq check . -o llm)
143
+ ```
144
+
145
+ Then invoke it with `/cq-fix` in Claude Code. The `$(...)` embeds the live `cq` output directly into the prompt before Claude starts, so it sees the issue immediately without an extra tool call.
146
+
147
+ **Hook vs skill:**
148
+ - **Stop hook** — automatic, runs after every session, best for unattended loops
149
+ - **Skill** — manual `/cq-fix`, gives you explicit control over when to check
150
+
118
151
  ## Table output
119
152
 
120
153
  ```bash
@@ -89,6 +89,39 @@ cq check . && deploy # block deploy on errors
89
89
  cq check . -o score # print score, exit 1 on errors
90
90
  ```
91
91
 
92
+ ## Claude Code Integration
93
+
94
+ Add a stop hook to your project's `.claude/settings.json` so Claude automatically checks quality after each session and loops until clean:
95
+
96
+ ```json
97
+ {
98
+ "hooks": {
99
+ "Stop": [{
100
+ "matcher": "",
101
+ "hooks": [{"type": "command", "command": "cq check . -o score && echo 'CQ: all clear' || cq check . -o llm"}]
102
+ }]
103
+ }
104
+ }
105
+ ```
106
+
107
+ When the score passes, Claude sees `CQ: all clear` (~5 tokens). When it fails, Claude receives the targeted fix prompt and continues working. This automates the `cq check . -o llm | claude -p "fix this"` loop.
108
+
109
+ > **Note:** Use project-level `.claude/settings.json`, not global settings — this hook only makes sense in Python projects.
110
+
111
+ ### As a slash command (skill)
112
+
113
+ For manual invocation, create `.claude/commands/cq-fix.md`:
114
+
115
+ ```markdown
116
+ $(cq check . -o llm)
117
+ ```
118
+
119
+ Then invoke it with `/cq-fix` in Claude Code. The `$(...)` embeds the live `cq` output directly into the prompt before Claude starts, so it sees the issue immediately without an extra tool call.
120
+
121
+ **Hook vs skill:**
122
+ - **Stop hook** — automatic, runs after every session, best for unattended loops
123
+ - **Skill** — manual `/cq-fix`, gives you explicit control over when to check
124
+
92
125
  ## Table output
93
126
 
94
127
  ```bash
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-code-quality"
3
- version = "0.1.9"
3
+ version = "0.1.10"
4
4
  description = "Python Code Quality Analysis Tool - feed the results from 11 CQ tools straight into an LLM. Minimal tokens."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -29,11 +29,11 @@ Homepage = "https://github.com/rhiza-fr/py-cq"
29
29
  Repository = "https://github.com/rhiza-fr/py-cq"
30
30
 
31
31
  [build-system]
32
- requires = ["hatchling"]
33
- build-backend = "hatchling.build"
32
+ requires = ["uv_build"]
33
+ build-backend = "uv_build"
34
34
 
35
- [tool.hatch.build.targets.wheel]
36
- packages = ["src/py_cq"]
35
+ [tool.uv.build-backend]
36
+ module-name = "py_cq"
37
37
 
38
38
  [project.scripts]
39
39
  cq = "py_cq.main:main"
@@ -1,65 +0,0 @@
1
- # Template: Multi-version Python testing workflow for Gitea Actions
2
- # Copy this file to your project's .gitea/workflows/ directory
3
- #
4
- # Runs tests against multiple Python versions using generic ubuntu runners.
5
- # Includes optional dependency upgrade testing.
6
-
7
- name: Python Tests
8
-
9
- on:
10
- push:
11
- branches: [main]
12
- pull_request:
13
- branches: [main]
14
-
15
- jobs:
16
- test:
17
- name: Python ${{ matrix.python-version }}
18
- runs-on: ubuntu-latest
19
- strategy:
20
- fail-fast: false
21
- matrix:
22
- python-version: ['3.12', '3.13']
23
-
24
- steps:
25
- - uses: actions/checkout@v4
26
-
27
- - name: Set up Python ${{ matrix.python-version }}
28
- uses: actions/setup-python@v5
29
- with:
30
- python-version: ${{ matrix.python-version }}
31
-
32
- - name: Install uv
33
- uses: astral-sh/setup-uv@v7
34
-
35
- - name: Install dependencies
36
- run: uv sync --all-extras
37
-
38
- - name: Run tests
39
- run: uv run pytest
40
-
41
- # Optional: Test if dependencies can be upgraded
42
- upgrade-test:
43
- name: Dependency Upgrade Test
44
- runs-on: ubuntu-latest
45
- continue-on-error: true # Don't fail the whole workflow if upgrades break
46
-
47
- steps:
48
- - uses: actions/checkout@v4
49
-
50
- - name: Set up Python
51
- uses: actions/setup-python@v5
52
- with:
53
- python-version: '3.14' # Test upgrades on latest Python
54
-
55
- - name: Install uv
56
- uses: astral-sh/setup-uv@v7
57
-
58
- - name: Upgrade all dependencies
59
- run: uv lock --upgrade
60
-
61
- - name: Install upgraded dependencies
62
- run: uv sync --all-extras
63
-
64
- - name: Run tests with upgraded dependencies
65
- run: uv run pytest
@@ -1,11 +0,0 @@
1
- name: Tests
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: python-test-image
8
- steps:
9
- - uses: actions/checkout@v4
10
- - run: uv sync --all-extras
11
- - run: uv run pytest
@@ -1,70 +0,0 @@
1
- # This workflow will upload a Python Package to PyPI when a release is created
2
- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
-
4
- # This workflow uses actions that are not certified by GitHub.
5
- # They are provided by a third-party and are governed by
6
- # separate terms of service, privacy policy, and support
7
- # documentation.
8
-
9
- name: Upload Python Package
10
-
11
- on:
12
- release:
13
- types: [published]
14
-
15
- permissions:
16
- contents: read
17
-
18
- jobs:
19
- release-build:
20
- runs-on: ubuntu-latest
21
-
22
- steps:
23
- - uses: actions/checkout@v4
24
-
25
- - name: Install uv
26
- uses: astral-sh/setup-uv@v5
27
-
28
- - name: Set up Python
29
- run: uv python install
30
-
31
- - name: Build release distributions
32
- run: |
33
- uv build
34
-
35
- - name: Upload distributions
36
- uses: actions/upload-artifact@v4
37
- with:
38
- name: release-dists
39
- path: dist/
40
-
41
- pypi-publish:
42
- runs-on: ubuntu-latest
43
- needs:
44
- - release-build
45
- permissions:
46
- # IMPORTANT: this permission is mandatory for trusted publishing
47
- id-token: write
48
-
49
- # Dedicated environments with protections for publishing are strongly recommended.
50
- # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51
- environment:
52
- name: pypi
53
- # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54
- # url: https://pypi.org/p/YOURPROJECT
55
- #
56
- # ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57
- # ALTERNATIVE: exactly, uncomment the following line instead:
58
- url: https://pypi.org/project/python-code-quality/${{ github.event.release.name }}
59
-
60
- steps:
61
- - name: Retrieve release distributions
62
- uses: actions/download-artifact@v4
63
- with:
64
- name: release-dists
65
- path: dist/
66
-
67
- - name: Publish release distributions to PyPI
68
- uses: pypa/gh-action-pypi-publish@release/v1
69
- with:
70
- packages-dir: dist/
@@ -1,18 +0,0 @@
1
- # Python-generated files
2
- __pycache__/
3
- *.py[oc]
4
- build/
5
- dist/
6
- wheels/
7
- *.egg-info
8
- .*_cache/
9
- # Virtual environments
10
- .venv
11
- profile.prof
12
- analysis_results.json
13
- .coverage
14
- .aider*
15
- .claude
16
- .cq.json
17
-
18
- docs/plans/*
@@ -1 +0,0 @@
1
- 3.14
@@ -1,54 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- CQ is a Python CLI tool for iterative, LLM-assisted code improvement. The primary use case is:
8
-
9
- ```bash
10
- cq check -o llm # returns the single most critical defect as markdown
11
- ```
12
-
13
- The LLM fixes it, the user re-runs, and repeats until all tools pass. CQ runs
14
- 11 static analysis tools in execution order (compile → security → lint → types →
15
- tests → coverage → complexity → dead code → style) and aggregates results into
16
- a single score.
17
-
18
- ## Commands
19
-
20
- ```bash
21
- # Run tests
22
- uv run pytest
23
-
24
- # Run a single test
25
- uv run pytest tests/test_common.py::test_score_logistic_variant
26
-
27
- # Run the CLI
28
- uv run cq check # table output, current directory
29
- uv run cq check -o llm # LLM markdown, primary use case
30
- uv run cq check -o score # numeric score
31
- uv run cq check path/to/project/
32
-
33
- # Lint
34
- uv run ruff check src/
35
- ```
36
-
37
- ## Architecture
38
-
39
- **Pipeline flow:** CLI (`cli.py`) → tool registry → execution engine → parsers → metric aggregator → output
40
-
41
- - **`cli.py`**: Typer app with a single `check` command. Output mode selected via `--output`/`-o` enum (`table`, `score`, `json`, `llm`). Runs tools in parallel by default. Reads `[tool.cq]` from the target project's `pyproject.toml` and applies overrides before running.
42
- - **`tool_registry.py`**: Loads `src/cq/config/config.yaml` at import time via `importlib.resources`, dynamically imports parser classes, builds a `dict[str, ToolConfig]` registry.
43
- - **`config/config.yaml`** (at `src/cq/config/config.yaml`): Declares each analysis tool: shell command template (with `{context_path}` placeholder), parser class name, order, warning/error thresholds. Tools are listed and executed in order.
44
- - **`execution_engine.py`**: Runs shell commands via `subprocess.run`, caches results with `diskcache` using a content-based hash. Parallel execution via `ThreadPoolExecutor`; results are sorted by order before returning.
45
- - **`parsers/`**: Each parser subclasses `AbstractParser` (from `localtypes.py`), implementing `parse(RawResult) -> ToolResult` and optionally `format_llm_message(ToolResult) -> str`. Parser module names must match the lowercase parser class name (e.g., `PytestParser` → `pytestparser.py`).
46
- - **`localtypes.py`**: Core dataclasses — `ToolConfig`, `RawResult`, `ToolResult`, `CombinedToolResults`, and `AbstractParser` ABC.
47
- - **`metric_aggregator.py`**: Wraps results into `CombinedToolResults`, which computes an overall score as the average of per-tool mean metrics.
48
- - **`llm_formatter.py`**: Selects the worst-scoring tool by severity tier then order, formats its top defect as markdown for LLM consumption.
49
-
50
- ## Adding a New Analysis Tool
51
-
52
- 1. Add tool entry in `config/config.yaml` with command template, parser name, order, and thresholds.
53
- 2. Create `src/cq/parsers/<parsername>.py` with a class matching the `parser` field in YAML.
54
- 3. The parser must subclass `AbstractParser` and implement `parse(RawResult) -> ToolResult`.
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Chris Kilner <chris@rhiza.fr>
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.
@@ -1,7 +0,0 @@
1
- """Shared test helpers."""
2
-
3
- from py_cq.localtypes import RawResult
4
-
5
-
6
- def raw(stdout="", return_code=0):
7
- return RawResult(tool_name="test", command="cmd", stdout=stdout, return_code=return_code)