codedoctor 0.1.3__tar.gz → 0.1.4__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.
- {codedoctor-0.1.3 → codedoctor-0.1.4}/CHANGELOG.md +17 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/PKG-INFO +34 -2
- {codedoctor-0.1.3 → codedoctor-0.1.4}/README.md +33 -1
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/affected.py +3 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/affected_test.py +29 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/backbone.py +5 -2
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/backbone_test.py +12 -2
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/codegraph_sync.py +6 -17
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/codegraph_sync_test.py +17 -37
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/cli.py +25 -3
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/cli_test.py +59 -1
- codedoctor-0.1.4/codedoctor/codegraph.py +116 -0
- codedoctor-0.1.4/codedoctor/codegraph_test.py +224 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/gate_test.py +21 -2
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/install.py +58 -76
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/install_test.py +130 -13
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/sidecars_test.py +22 -9
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/houselint_rules.py +23 -4
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/houselint_rules_test.py +96 -17
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/houselint_test.py +27 -7
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutated.py +234 -138
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutated_test.py +398 -36
- codedoctor-0.1.4/codedoctor/policy.py +254 -0
- codedoctor-0.1.4/codedoctor/policy_test.py +191 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/testing.py +32 -8
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/testing_test.py +71 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/pyproject.toml +3 -4
- {codedoctor-0.1.3 → codedoctor-0.1.4}/uv.lock +2 -2
- {codedoctor-0.1.3 → codedoctor-0.1.4}/.gitignore +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/.pre-commit-config.yaml +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/.python-version +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/AI_POLICY.md +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/CODE_OF_CONDUCT.md +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/CONTRIBUTING.md +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/LICENSE +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/RELEASING.md +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/SECURITY.md +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/affected/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/assert_isinstance/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/assert_isinstance/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/assert_isinstance/unnecessary_assert_isinstance.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/assert_isinstance/unnecessary_assert_isinstance_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/coverage_floor/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/coverage_floor/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/coverage_floor/coverage_floor.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/coverage_floor/coverage_floor_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/export_leaks/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/export_leaks/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/export_leaks/check_export_leaks.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/export_leaks/check_export_leaks_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/export_leaks/check_pr_text.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/export_leaks/check_pr_text_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/fakes.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/fakes_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/gate.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/spool.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/gate/spool_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/install_hooks.yaml +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/glob.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/glob_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/grep.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/grep_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/owner_only.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/owner_only_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/source_version.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/source_version_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/tempclaim.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/tempclaim_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/walk.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/files/walk_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/kernel_pins.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/kernel_pins_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/pyproject_flags.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/pyproject_flags_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/sidecars.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/basetemp.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/checks.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/checks_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/resources.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/runner.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/runner_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/testing/wheel.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/userdirs.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/worker_count.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lib/worker_count_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/house_ignore.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/house_ignore_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/houselint.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/houselint_types.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/lint/houselint_types_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_dynamo.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_dynamo_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_kill_guard.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_kill_guard_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_outcome.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_outcome_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_param_ids.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_param_ids_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/nbstripout/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/nbstripout/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/nbstripout/nbstripout_hook.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/nbstripout/nbstripout_hook_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/py.typed +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/coverage_summary.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/coverage_summary_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/listing.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/listing_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/outcomes.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/outcomes_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/tiers.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/testing/tiers_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/typecheck/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/typecheck/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/typecheck/scope.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/typecheck/scope_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/typecheck/typecheck.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/typecheck/typecheck_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/yamlcheck/__init__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/yamlcheck/__main__.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/yamlcheck/checker.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/codedoctor/yamlcheck/checker_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/conftest.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/tests/lib/testing/basetemp_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/tests/lib/testing/resources_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/tests/lib/testing/wheel_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/tests/lib/userdirs_test.py +0 -0
- {codedoctor-0.1.3 → codedoctor-0.1.4}/typings/.gitkeep +0 -0
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable codedoctor changes are documented here. This project follows
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
5
|
|
|
6
|
+
## 0.1.4 - 2026-11-07
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- Provision pinned, checksummed CodeGraph and skip indexing when unavailable.
|
|
11
|
+
- Generate checker policy from packaged defaults, preserving project overrides.
|
|
12
|
+
- Check for stale generated configuration.
|
|
13
|
+
- Require explicit project settings for user-directory lint rules.
|
|
14
|
+
- Apply coverage floors to sources owned by changed tests.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Preserve leading whitespace in hook configuration.
|
|
19
|
+
- Prove integer bounds for NumPy `arange` defaults.
|
|
20
|
+
- Restrict mutation's vendored-tree filter to stub directories.
|
|
21
|
+
- Fix mutant import shadowing.
|
|
22
|
+
|
|
6
23
|
## 0.1.3 - 2026-11-07
|
|
7
24
|
|
|
8
25
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: codedoctor
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Pre-commit gates that run each heavy check once, sized to the machine.
|
|
5
5
|
Project-URL: Homepage, https://www.rekursiv.ai
|
|
6
6
|
Project-URL: Repository, https://github.com/rekursiv-ai/codedoctor
|
|
@@ -90,9 +90,21 @@ uv run --group pre-commit pre-commit run --all-files
|
|
|
90
90
|
|
|
91
91
|
`codedoctor install` adds a locked `pre-commit` dependency group and installs
|
|
92
92
|
pre-commit and pre-push Git hooks. It creates missing configuration and preserves
|
|
93
|
-
existing hooks, comments,
|
|
93
|
+
existing hooks, comments, hook arguments, and the project's Python support range.
|
|
94
94
|
Running it again does not duplicate hooks.
|
|
95
95
|
|
|
96
|
+
The installer writes Ruff, ty, basedpyright, and pyrefly settings from the
|
|
97
|
+
package's bundled policy into `pyproject.toml`. It also configures pytest,
|
|
98
|
+
coverage floors, and mutation source selection. That policy comes from Loop's
|
|
99
|
+
canonical configuration, with checkout-specific paths removed. Existing project
|
|
100
|
+
settings remain overrides; installation reports their names.
|
|
101
|
+
|
|
102
|
+
Codedoctor is development tooling, not an application dependency. Applications
|
|
103
|
+
can use their own user-directory helpers or inline XDG handling. The installer
|
|
104
|
+
uses the project name for `userdirs-namespace.namespace`; set it explicitly in
|
|
105
|
+
`[tool.houselint]` to choose another namespace. `xdg-literal.helper` is unset
|
|
106
|
+
unless the project requires a shared helper.
|
|
107
|
+
|
|
96
108
|
Setup uses the same hook configuration as this repository, without its
|
|
97
109
|
package-export and Rust-only checks. Commits autofix whitespace, spelling,
|
|
98
110
|
notebooks, house lint, and Ruff formatting; check types with ty, pyrefly, and
|
|
@@ -120,6 +132,26 @@ Codedoctor requires Python 3.12 or newer. For projects supporting older Python,
|
|
|
120
132
|
use the `uvx` route: its tools live in a Python 3.12+ dependency group without
|
|
121
133
|
raising the application's runtime floor. Git and uv must already be installed.
|
|
122
134
|
|
|
135
|
+
## Policy updates
|
|
136
|
+
|
|
137
|
+
Policy changes reach projects through a new Codedoctor release. Upgrade the
|
|
138
|
+
locked dependency, then reinstall:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
uv lock --upgrade-package codedoctor
|
|
142
|
+
uv run --group pre-commit codedoctor install
|
|
143
|
+
uv run --group pre-commit codedoctor check
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`[tool.codedoctor.managed]` records the last generated defaults. Reinstallation
|
|
147
|
+
updates unchanged managed settings and adds new defaults. It preserves project
|
|
148
|
+
overrides and deliberately deleted settings. Lists are replaced as whole values;
|
|
149
|
+
a customized list remains an override. Do not edit the recorded baseline.
|
|
150
|
+
|
|
151
|
+
`codedoctor check` exits nonzero when the installed package would refresh the
|
|
152
|
+
project configuration. It does not write files or install dependencies. Preserved
|
|
153
|
+
overrides do not make configuration stale.
|
|
154
|
+
|
|
123
155
|
pre-commit calls a hook once per chunk of file names, so `--all-files` starts a
|
|
124
156
|
type checker or pytest several times over. Each heavy gate here is two hooks: a
|
|
125
157
|
`-spool` twin collects every chunk, then the gate runs once over all of them,
|
|
@@ -22,9 +22,21 @@ uv run --group pre-commit pre-commit run --all-files
|
|
|
22
22
|
|
|
23
23
|
`codedoctor install` adds a locked `pre-commit` dependency group and installs
|
|
24
24
|
pre-commit and pre-push Git hooks. It creates missing configuration and preserves
|
|
25
|
-
existing hooks, comments,
|
|
25
|
+
existing hooks, comments, hook arguments, and the project's Python support range.
|
|
26
26
|
Running it again does not duplicate hooks.
|
|
27
27
|
|
|
28
|
+
The installer writes Ruff, ty, basedpyright, and pyrefly settings from the
|
|
29
|
+
package's bundled policy into `pyproject.toml`. It also configures pytest,
|
|
30
|
+
coverage floors, and mutation source selection. That policy comes from Loop's
|
|
31
|
+
canonical configuration, with checkout-specific paths removed. Existing project
|
|
32
|
+
settings remain overrides; installation reports their names.
|
|
33
|
+
|
|
34
|
+
Codedoctor is development tooling, not an application dependency. Applications
|
|
35
|
+
can use their own user-directory helpers or inline XDG handling. The installer
|
|
36
|
+
uses the project name for `userdirs-namespace.namespace`; set it explicitly in
|
|
37
|
+
`[tool.houselint]` to choose another namespace. `xdg-literal.helper` is unset
|
|
38
|
+
unless the project requires a shared helper.
|
|
39
|
+
|
|
28
40
|
Setup uses the same hook configuration as this repository, without its
|
|
29
41
|
package-export and Rust-only checks. Commits autofix whitespace, spelling,
|
|
30
42
|
notebooks, house lint, and Ruff formatting; check types with ty, pyrefly, and
|
|
@@ -52,6 +64,26 @@ Codedoctor requires Python 3.12 or newer. For projects supporting older Python,
|
|
|
52
64
|
use the `uvx` route: its tools live in a Python 3.12+ dependency group without
|
|
53
65
|
raising the application's runtime floor. Git and uv must already be installed.
|
|
54
66
|
|
|
67
|
+
## Policy updates
|
|
68
|
+
|
|
69
|
+
Policy changes reach projects through a new Codedoctor release. Upgrade the
|
|
70
|
+
locked dependency, then reinstall:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
uv lock --upgrade-package codedoctor
|
|
74
|
+
uv run --group pre-commit codedoctor install
|
|
75
|
+
uv run --group pre-commit codedoctor check
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`[tool.codedoctor.managed]` records the last generated defaults. Reinstallation
|
|
79
|
+
updates unchanged managed settings and adds new defaults. It preserves project
|
|
80
|
+
overrides and deliberately deleted settings. Lists are replaced as whole values;
|
|
81
|
+
a customized list remains an override. Do not edit the recorded baseline.
|
|
82
|
+
|
|
83
|
+
`codedoctor check` exits nonzero when the installed package would refresh the
|
|
84
|
+
project configuration. It does not write files or install dependencies. Preserved
|
|
85
|
+
overrides do not make configuration stale.
|
|
86
|
+
|
|
55
87
|
pre-commit calls a hook once per chunk of file names, so `--all-files` starts a
|
|
56
88
|
type checker or pytest several times over. Each heavy gate here is two hooks: a
|
|
57
89
|
`-spool` twin collects every chunk, then the gate runs once over all of them,
|
|
@@ -35,6 +35,7 @@ import tomllib
|
|
|
35
35
|
|
|
36
36
|
from treekle import ReadError, from_plain
|
|
37
37
|
|
|
38
|
+
from codedoctor import codegraph
|
|
38
39
|
from codedoctor.affected import backbone
|
|
39
40
|
from codedoctor.gate.gate import skipped
|
|
40
41
|
from codedoctor.lib import sidecars
|
|
@@ -83,6 +84,8 @@ def main() -> int:
|
|
|
83
84
|
)
|
|
84
85
|
if database is None:
|
|
85
86
|
database = Path.cwd() / ".codegraph" / "codegraph.db"
|
|
87
|
+
if depth > 0 and not saturated and codegraph.executable() is None:
|
|
88
|
+
depth = 0
|
|
86
89
|
if depth > 0 and not saturated:
|
|
87
90
|
problem = backbone.sync_worktree(
|
|
88
91
|
Path.cwd(),
|
|
@@ -19,6 +19,7 @@ import threading
|
|
|
19
19
|
|
|
20
20
|
import pytest
|
|
21
21
|
|
|
22
|
+
from codedoctor import codegraph
|
|
22
23
|
from codedoctor.affected import affected, backbone
|
|
23
24
|
from codedoctor.affected.affected import collection_patterns, harvest
|
|
24
25
|
|
|
@@ -42,6 +43,7 @@ def in_tmp_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
|
42
43
|
passes here, and only diverges once the two configs do.
|
|
43
44
|
"""
|
|
44
45
|
monkeypatch.chdir(tmp_path)
|
|
46
|
+
monkeypatch.setattr(codegraph, "executable", lambda: "codegraph")
|
|
45
47
|
monkeypatch.setattr(
|
|
46
48
|
backbone,
|
|
47
49
|
"sync_worktree",
|
|
@@ -2182,6 +2184,31 @@ def test_the_rebuilds_index_output_never_reaches_the_selection(
|
|
|
2182
2184
|
assert "Initializing CodeGraph" in err
|
|
2183
2185
|
|
|
2184
2186
|
|
|
2187
|
+
@pytest.mark.parametrize("emit", ["files", "nodeids"])
|
|
2188
|
+
def test_a_missing_cli_selects_without_indexing_or_diagnostics(
|
|
2189
|
+
tmp_path: Path,
|
|
2190
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
2191
|
+
capsys: pytest.CaptureFixture[str],
|
|
2192
|
+
emit: str,
|
|
2193
|
+
) -> None:
|
|
2194
|
+
(tmp_path / "lib.py").touch()
|
|
2195
|
+
(tmp_path / "lib_test.py").touch()
|
|
2196
|
+
monkeypatch.delenv("SKIP", raising=False)
|
|
2197
|
+
monkeypatch.setattr(codegraph, "executable", lambda: None)
|
|
2198
|
+
sync = Mock(side_effect=AssertionError("missing CodeGraph was invoked"))
|
|
2199
|
+
monkeypatch.setattr(backbone, "sync_worktree", sync)
|
|
2200
|
+
monkeypatch.setattr(
|
|
2201
|
+
sys,
|
|
2202
|
+
"argv",
|
|
2203
|
+
["affected", "--no-universe", "--depth", "2", "--emit", emit, "--", "lib.py"],
|
|
2204
|
+
)
|
|
2205
|
+
|
|
2206
|
+
assert affected.main() == 0
|
|
2207
|
+
expected = "lib.py\n" if emit == "files" else "lib_test.py\n"
|
|
2208
|
+
assert capsys.readouterr() == (expected, "")
|
|
2209
|
+
sync.assert_not_called()
|
|
2210
|
+
|
|
2211
|
+
|
|
2185
2212
|
def test_a_missing_index_cli_exits_127_like_a_shell(
|
|
2186
2213
|
tmp_path: Path,
|
|
2187
2214
|
capfd: pytest.CaptureFixture[str],
|
|
@@ -3058,10 +3085,12 @@ def test_an_explicit_database_is_read_alone(
|
|
|
3058
3085
|
"""`--database` names an index to walk as it stands, with no overlay."""
|
|
3059
3086
|
calls = _recorded_harvest(monkeypatch)
|
|
3060
3087
|
monkeypatch.delenv("SKIP", raising=False)
|
|
3088
|
+
monkeypatch.setattr(codegraph, "executable", lambda: None)
|
|
3061
3089
|
monkeypatch.setattr(sys, "argv", ["affected", "--database", "x.db", "--", "x.py"])
|
|
3062
3090
|
|
|
3063
3091
|
assert affected.main() == 0
|
|
3064
3092
|
assert (calls[0]["database"], calls[0]["overlay"]) == (Path("x.db"), None)
|
|
3093
|
+
assert calls[0]["depth"] == 1
|
|
3065
3094
|
|
|
3066
3095
|
|
|
3067
3096
|
if __name__ == "__main__":
|
|
@@ -27,6 +27,8 @@ import shutil
|
|
|
27
27
|
import sqlite3
|
|
28
28
|
import tempfile
|
|
29
29
|
|
|
30
|
+
from codedoctor import codegraph
|
|
31
|
+
|
|
30
32
|
|
|
31
33
|
if TYPE_CHECKING:
|
|
32
34
|
from collections.abc import Callable, Sequence
|
|
@@ -291,10 +293,11 @@ def index_tree(tree: Path, *, run: Callable[[Sequence[str]], int]) -> int:
|
|
|
291
293
|
status: The CLI's exit code.
|
|
292
294
|
|
|
293
295
|
"""
|
|
296
|
+
binary = codegraph.executable() or "codegraph"
|
|
294
297
|
return run(
|
|
295
|
-
[
|
|
298
|
+
[binary, "sync", "--quiet", str(tree)]
|
|
296
299
|
if (tree / ".codegraph" / "codegraph.db").is_file()
|
|
297
|
-
else [
|
|
300
|
+
else [binary, "init", "--yes", str(tree)],
|
|
298
301
|
)
|
|
299
302
|
|
|
300
303
|
|
|
@@ -15,6 +15,7 @@ import subprocess
|
|
|
15
15
|
|
|
16
16
|
import pytest
|
|
17
17
|
|
|
18
|
+
from codedoctor import codegraph
|
|
18
19
|
from codedoctor.affected import backbone
|
|
19
20
|
from codedoctor.gate.gate import output_argv
|
|
20
21
|
|
|
@@ -28,6 +29,11 @@ _SHA = "a" * 40
|
|
|
28
29
|
_LONG = "0123456789abcdef" * 2 + "01234567"
|
|
29
30
|
|
|
30
31
|
|
|
32
|
+
@pytest.fixture(autouse=True)
|
|
33
|
+
def isolated_executable(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
34
|
+
monkeypatch.setattr(codegraph, "executable", lambda: "codegraph")
|
|
35
|
+
|
|
36
|
+
|
|
31
37
|
def _codegraph(database: Path, *, files: Sequence[str] = ()) -> Path:
|
|
32
38
|
"""Write a CodeGraph-shaped index holding one function per file in ``files``."""
|
|
33
39
|
database.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -107,11 +113,15 @@ def _indexer(calls: list[Path]) -> Callable[[Path], int]:
|
|
|
107
113
|
|
|
108
114
|
@pytest.mark.parametrize("status", [0, 3])
|
|
109
115
|
@pytest.mark.parametrize("initialized", [False, True])
|
|
116
|
+
@pytest.mark.parametrize("binary", [None, "/managed/codegraph"])
|
|
110
117
|
def test_a_tree_syncs_its_existing_index_or_initializes_once(
|
|
111
118
|
tmp_path: Path,
|
|
119
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
112
120
|
status: int,
|
|
113
121
|
initialized: bool,
|
|
122
|
+
binary: str | None,
|
|
114
123
|
) -> None:
|
|
124
|
+
monkeypatch.setattr(codegraph, "executable", lambda: binary)
|
|
115
125
|
if initialized:
|
|
116
126
|
_codegraph(tmp_path / ".codegraph" / "codegraph.db")
|
|
117
127
|
seen: list[list[str]] = []
|
|
@@ -122,9 +132,9 @@ def test_a_tree_syncs_its_existing_index_or_initializes_once(
|
|
|
122
132
|
|
|
123
133
|
assert backbone.index_tree(tmp_path, run=run) == status
|
|
124
134
|
assert seen == [
|
|
125
|
-
["codegraph", "sync", "--quiet", str(tmp_path)]
|
|
135
|
+
[binary or "codegraph", "sync", "--quiet", str(tmp_path)]
|
|
126
136
|
if initialized
|
|
127
|
-
else ["codegraph", "init", "--yes", str(tmp_path)],
|
|
137
|
+
else [binary or "codegraph", "init", "--yes", str(tmp_path)],
|
|
128
138
|
]
|
|
129
139
|
|
|
130
140
|
|
|
@@ -6,8 +6,8 @@ exec uv --quiet --project "$(dirname "$0")" run --frozen --no-sync python3 -P "$
|
|
|
6
6
|
Keep this worktree's CodeGraph index current.
|
|
7
7
|
|
|
8
8
|
Hook mode runs when an enabled hook's resolved PRECOMMIT_SCOPE needs the graph.
|
|
9
|
-
It
|
|
10
|
-
|
|
9
|
+
It skips indexing when the CLI is missing; `codedoctor install` provisions it.
|
|
10
|
+
It never resolves or fetches a commit. It never fails a commit:
|
|
11
11
|
a problem is printed, and `affected` retries before selecting dependents.
|
|
12
12
|
|
|
13
13
|
--refresh republishes the backbone at origin/main; a timer runs it with --fetch.
|
|
@@ -37,6 +37,7 @@ import sqlite3
|
|
|
37
37
|
import subprocess
|
|
38
38
|
import sys
|
|
39
39
|
|
|
40
|
+
from codedoctor import codegraph
|
|
40
41
|
from codedoctor.affected import backbone
|
|
41
42
|
from codedoctor.affected.affected import ensure_derived
|
|
42
43
|
from codedoctor.gate.gate import output_argv, run_argv, scope, skipped
|
|
@@ -82,7 +83,6 @@ def main() -> int:
|
|
|
82
83
|
Path.cwd(),
|
|
83
84
|
caches=flags.caches,
|
|
84
85
|
run=run_argv,
|
|
85
|
-
which=shutil.which,
|
|
86
86
|
)
|
|
87
87
|
):
|
|
88
88
|
sys.stderr.write(f"codegraph-sync: {problem}\n")
|
|
@@ -113,7 +113,6 @@ def sync(
|
|
|
113
113
|
*,
|
|
114
114
|
caches: Path,
|
|
115
115
|
run: Callable[[Sequence[str]], int],
|
|
116
|
-
which: Callable[[str], str | None],
|
|
117
116
|
) -> str:
|
|
118
117
|
"""Sync the current worktree's files into its CodeGraph index.
|
|
119
118
|
|
|
@@ -121,19 +120,13 @@ def sync(
|
|
|
121
120
|
root: The worktree.
|
|
122
121
|
caches: The CodeGraph cache directory.
|
|
123
122
|
run: Runs one argv; returns its exit code.
|
|
124
|
-
which: Finds an executable on PATH.
|
|
125
123
|
|
|
126
124
|
Returns:
|
|
127
125
|
problem: Why the gates must select without the graph; empty otherwise.
|
|
128
126
|
|
|
129
127
|
"""
|
|
130
|
-
if
|
|
131
|
-
|
|
132
|
-
if which("codegraph") is None:
|
|
133
|
-
return (
|
|
134
|
-
"The codegraph CLI is missing, and `npm install -g "
|
|
135
|
-
"@colbymchenry/codegraph` did not install it."
|
|
136
|
-
)
|
|
128
|
+
if codegraph.executable() is None:
|
|
129
|
+
return "Skipped: CodeGraph is not installed; run `codedoctor install`."
|
|
137
130
|
return backbone.sync_worktree(root, caches=caches, run=run)
|
|
138
131
|
|
|
139
132
|
|
|
@@ -311,11 +304,7 @@ def _refresh_locked(
|
|
|
311
304
|
):
|
|
312
305
|
return f"`git read-tree` of {sha[:12]} failed (exit {status})."
|
|
313
306
|
working = tree / ".codegraph" / "codegraph.db"
|
|
314
|
-
if status := run
|
|
315
|
-
["codegraph", "sync", "--quiet", str(tree)]
|
|
316
|
-
if working.is_file()
|
|
317
|
-
else ["codegraph", "init", "--yes", str(tree)],
|
|
318
|
-
):
|
|
307
|
+
if status := backbone.index_tree(tree, run=run):
|
|
319
308
|
return f"Indexing {sha[:12]} failed (codegraph exit {status})."
|
|
320
309
|
_publish(working, database, sha=sha)
|
|
321
310
|
if ensure_derived(database) is None:
|
|
@@ -8,13 +8,13 @@ from typing import TYPE_CHECKING
|
|
|
8
8
|
|
|
9
9
|
import fcntl
|
|
10
10
|
import os
|
|
11
|
-
import shutil
|
|
12
11
|
import sqlite3
|
|
13
12
|
import subprocess
|
|
14
13
|
import sys
|
|
15
14
|
|
|
16
15
|
import pytest
|
|
17
16
|
|
|
17
|
+
from codedoctor import codegraph
|
|
18
18
|
from codedoctor.affected import backbone, codegraph_sync
|
|
19
19
|
from codedoctor.gate.gate import output_argv, run_argv
|
|
20
20
|
|
|
@@ -26,8 +26,13 @@ if TYPE_CHECKING:
|
|
|
26
26
|
_OLD, _NEW = "a" * 40, "b" * 40
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
@pytest.fixture(autouse=True)
|
|
30
|
+
def isolated_executable(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
31
|
+
monkeypatch.setattr(codegraph, "executable", lambda: "codegraph")
|
|
32
|
+
|
|
33
|
+
|
|
29
34
|
class _Tools:
|
|
30
|
-
"""
|
|
35
|
+
"""Stand in for Git and CodeGraph; record every argv."""
|
|
31
36
|
|
|
32
37
|
def __init__(
|
|
33
38
|
self,
|
|
@@ -35,14 +40,10 @@ class _Tools:
|
|
|
35
40
|
sha: str = _NEW,
|
|
36
41
|
codegraph: int = 0,
|
|
37
42
|
diff: str = "",
|
|
38
|
-
installed: bool = True,
|
|
39
|
-
installable: bool = False,
|
|
40
43
|
) -> None:
|
|
41
44
|
self.sha = sha
|
|
42
45
|
self.codegraph = codegraph
|
|
43
46
|
self.diff = diff
|
|
44
|
-
self.installed = installed
|
|
45
|
-
self.installable = installable
|
|
46
47
|
self.calls: list[list[str]] = []
|
|
47
48
|
|
|
48
49
|
def run(self, argv: Sequence[str]) -> int:
|
|
@@ -59,14 +60,6 @@ class _Tools:
|
|
|
59
60
|
return f"{self.sha}\n" if self.sha else None
|
|
60
61
|
return self.diff if "diff" in argv else ""
|
|
61
62
|
|
|
62
|
-
def which(self, name: str) -> str | None:
|
|
63
|
-
"""Find only the codegraph CLI: installed, or installable and installed by npm."""
|
|
64
|
-
npm = ["npm", "install", "-g", "@colbymchenry/codegraph"]
|
|
65
|
-
found = name == "codegraph" and (
|
|
66
|
-
self.installed or (self.installable and npm in self.calls)
|
|
67
|
-
)
|
|
68
|
-
return f"/bin/{name}" if found else None
|
|
69
|
-
|
|
70
63
|
def ran(self, tool: str) -> list[list[str]]:
|
|
71
64
|
"""Return the recorded argvs holding the word ``tool``."""
|
|
72
65
|
return [argv for argv in self.calls if tool in argv]
|
|
@@ -104,7 +97,6 @@ def _sync(tmp_path: Path, tools: _Tools) -> str:
|
|
|
104
97
|
root,
|
|
105
98
|
caches=tmp_path / "caches",
|
|
106
99
|
run=tools.run,
|
|
107
|
-
which=tools.which,
|
|
108
100
|
)
|
|
109
101
|
|
|
110
102
|
|
|
@@ -484,28 +476,17 @@ def test_current_files_are_indexed_by_the_codegraph_cli(tmp_path: Path) -> None:
|
|
|
484
476
|
]
|
|
485
477
|
|
|
486
478
|
|
|
487
|
-
def
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
assert
|
|
494
|
-
"
|
|
495
|
-
"@colbymchenry/codegraph` did not install it."
|
|
479
|
+
def test_a_missing_cli_skips_without_running_or_installing(
|
|
480
|
+
tmp_path: Path,
|
|
481
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
482
|
+
) -> None:
|
|
483
|
+
tools = _Tools()
|
|
484
|
+
monkeypatch.setattr(codegraph, "executable", lambda: None)
|
|
485
|
+
assert _sync(tmp_path, tools) == (
|
|
486
|
+
"Skipped: CodeGraph is not installed; run `codedoctor install`."
|
|
496
487
|
)
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
def test_a_missing_cli_is_installed_then_used(tmp_path: Path) -> None:
|
|
500
|
-
tools = _Tools(installed=False, installable=True)
|
|
501
|
-
|
|
502
|
-
problem = _sync(tmp_path, tools)
|
|
503
|
-
|
|
504
|
-
assert tools.calls == [
|
|
505
|
-
["npm", "install", "-g", "@colbymchenry/codegraph"],
|
|
506
|
-
["codegraph", "init", "--yes", str(tmp_path / "root")],
|
|
507
|
-
]
|
|
508
|
-
assert problem == ""
|
|
488
|
+
assert tools.calls == []
|
|
489
|
+
assert not (tmp_path / "root" / ".codegraph").exists()
|
|
509
490
|
|
|
510
491
|
|
|
511
492
|
def test_an_installed_cli_is_not_reinstalled(tmp_path: Path) -> None:
|
|
@@ -566,7 +547,6 @@ def _main(
|
|
|
566
547
|
assert kwargs == {
|
|
567
548
|
"caches": caches,
|
|
568
549
|
"run": run_argv,
|
|
569
|
-
"which": shutil.which,
|
|
570
550
|
}
|
|
571
551
|
called.append(f"sync {root}")
|
|
572
552
|
return "overlay problem"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import cast
|
|
6
|
+
from typing import Protocol, cast
|
|
7
7
|
|
|
8
8
|
import argparse
|
|
9
9
|
import shutil
|
|
@@ -24,7 +24,7 @@ def main() -> int:
|
|
|
24
24
|
"""
|
|
25
25
|
parser = argparse.ArgumentParser(description=(__doc__ or "").strip())
|
|
26
26
|
_add_arguments(parser)
|
|
27
|
-
parser.parse_args()
|
|
27
|
+
flags = cast(Flags, parser.parse_args())
|
|
28
28
|
try:
|
|
29
29
|
root = subprocess.run( # noqa: S603 -- Fixed Git command, no user input.
|
|
30
30
|
[shutil.which("git") or "git", "rev-parse", "--show-toplevel"],
|
|
@@ -32,13 +32,25 @@ def main() -> int:
|
|
|
32
32
|
capture_output=True,
|
|
33
33
|
text=True,
|
|
34
34
|
)
|
|
35
|
-
|
|
35
|
+
if flags.command == "check":
|
|
36
|
+
if install.current(Path(root.stdout.strip())):
|
|
37
|
+
sys.stdout.write("Codedoctor configuration is current.\n")
|
|
38
|
+
return 0
|
|
39
|
+
sys.stderr.write(
|
|
40
|
+
"Codedoctor configuration is stale; run `codedoctor install`.\n",
|
|
41
|
+
)
|
|
42
|
+
return 1
|
|
43
|
+
overrides = install.install(Path(root.stdout.strip()))
|
|
36
44
|
except subprocess.CalledProcessError as error:
|
|
37
45
|
sys.stderr.write(f"codedoctor: {cast(object, error.stderr) or error}\n")
|
|
38
46
|
return error.returncode
|
|
39
47
|
except (OSError, ValueError, TypeError, yaml.YAMLError) as error:
|
|
40
48
|
sys.stderr.write(f"codedoctor: {error}\n")
|
|
41
49
|
return 1
|
|
50
|
+
if overrides:
|
|
51
|
+
sys.stderr.write(
|
|
52
|
+
"Codedoctor preserved project overrides: " + ", ".join(overrides) + "\n",
|
|
53
|
+
)
|
|
42
54
|
sys.stdout.write(
|
|
43
55
|
"Codedoctor installed: Ruff, ty, paired tests, and pre-push checks.\n"
|
|
44
56
|
"Check existing files: uv run --group pre-commit pre-commit run --all-files\n",
|
|
@@ -46,7 +58,17 @@ def main() -> int:
|
|
|
46
58
|
return 0
|
|
47
59
|
|
|
48
60
|
|
|
61
|
+
class Flags(Protocol):
|
|
62
|
+
"""Parsed repository setup command."""
|
|
63
|
+
|
|
64
|
+
command: str
|
|
65
|
+
|
|
66
|
+
|
|
49
67
|
def _add_arguments(parser: argparse.ArgumentParser) -> None:
|
|
50
68
|
"""Register repository setup commands."""
|
|
51
69
|
commands = parser.add_subparsers(dest="command", required=True)
|
|
52
70
|
commands.add_parser("install", help="Configure tools and install Git hooks.")
|
|
71
|
+
commands.add_parser(
|
|
72
|
+
"check",
|
|
73
|
+
help="Check generated policy freshness without modifying files.",
|
|
74
|
+
)
|
|
@@ -34,7 +34,12 @@ def test_install_from_nested_directory(
|
|
|
34
34
|
) -> None:
|
|
35
35
|
installed: list[Path] = []
|
|
36
36
|
monkeypatch.setattr(sys, "argv", ["codedoctor", "install"])
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
def configure(root: Path) -> tuple[str, ...]:
|
|
39
|
+
installed.append(root)
|
|
40
|
+
return ()
|
|
41
|
+
|
|
42
|
+
monkeypatch.setattr(install, "install", configure)
|
|
38
43
|
|
|
39
44
|
def root(
|
|
40
45
|
argv: Sequence[str],
|
|
@@ -129,6 +134,59 @@ def test_help_description_tracks_the_module(
|
|
|
129
134
|
assert result.value.code == 0
|
|
130
135
|
|
|
131
136
|
|
|
137
|
+
@pytest.mark.parametrize("current", [True, False])
|
|
138
|
+
def test_check_reports_stale_policy_without_installing(
|
|
139
|
+
current: bool,
|
|
140
|
+
tmp_path: Path,
|
|
141
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
142
|
+
capsys: pytest.CaptureFixture[str],
|
|
143
|
+
) -> None:
|
|
144
|
+
monkeypatch.setattr(sys, "argv", ["codedoctor", "check"])
|
|
145
|
+
|
|
146
|
+
def root(*args: object, **kwargs: object) -> subprocess.CompletedProcess[str]:
|
|
147
|
+
del args, kwargs
|
|
148
|
+
return subprocess.CompletedProcess([], 0, stdout=str(tmp_path))
|
|
149
|
+
|
|
150
|
+
def check(path: Path) -> bool:
|
|
151
|
+
assert path == tmp_path
|
|
152
|
+
return current
|
|
153
|
+
|
|
154
|
+
monkeypatch.setattr(subprocess, "run", root)
|
|
155
|
+
monkeypatch.setattr(install, "current", check)
|
|
156
|
+
assert cli.main() == (0 if current else 1)
|
|
157
|
+
captured = capsys.readouterr()
|
|
158
|
+
assert captured.out == ("Codedoctor configuration is current.\n" if current else "")
|
|
159
|
+
assert captured.err == (
|
|
160
|
+
""
|
|
161
|
+
if current
|
|
162
|
+
else "Codedoctor configuration is stale; run `codedoctor install`.\n"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def test_install_reports_preserved_overrides(
|
|
167
|
+
tmp_path: Path,
|
|
168
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
169
|
+
capsys: pytest.CaptureFixture[str],
|
|
170
|
+
) -> None:
|
|
171
|
+
monkeypatch.setattr(sys, "argv", ["codedoctor", "install"])
|
|
172
|
+
|
|
173
|
+
def root(*args: object, **kwargs: object) -> subprocess.CompletedProcess[str]:
|
|
174
|
+
del args, kwargs
|
|
175
|
+
return subprocess.CompletedProcess([], 0, stdout=str(tmp_path))
|
|
176
|
+
|
|
177
|
+
def configure(path: Path) -> tuple[str, ...]:
|
|
178
|
+
assert path == tmp_path
|
|
179
|
+
return ("ruff.line-length", "ty.rules.all")
|
|
180
|
+
|
|
181
|
+
monkeypatch.setattr(subprocess, "run", root)
|
|
182
|
+
monkeypatch.setattr(install, "install", configure)
|
|
183
|
+
assert cli.main() == 0
|
|
184
|
+
assert (
|
|
185
|
+
capsys.readouterr().err
|
|
186
|
+
== "Codedoctor preserved project overrides: ruff.line-length, ty.rules.all\n"
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
132
190
|
if __name__ == "__main__":
|
|
133
191
|
from codedoctor.lib.testing.runner import test_main
|
|
134
192
|
|