Compare commits

..

3 Commits

Author SHA1 Message Date
db69c7251b Add a session prompt to raise pylint --fail-under from 8.0 to 10 fleet-wide
Some checks are pending
crdt-sync pre-commit / pre-commit (push) Waiting to run
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
freedays pre-commit / pre-commit (push) Waiting to run
gatelock pre-commit / pre-commit (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
A --fail-under=8.0 gate tolerates two points of lint debt permanently and
lets a score regress from 9.9 to 8.1 without failing anything.

Surveyed every repo under ~/src and ~/praca_magisterska: ten pylint hooks
across six repos still sit at 8.0, while five sites already run at 10 --
so this adopts an existing standard rather than inventing one. The prompt
carries the exact file:line of all ten, including the second pylint hook in
screen-locker that a naive sweep would miss.

Measured the sizing rather than guessing at it, because the raw numbers are
misleading. These configs run enable = "all" with disable = [], so the
findings are dominated by test-file idioms -- 147 redefined-outer-name in
gatelock is pytest fixtures, not defects. The repos already at 10 resolved
this and documented why: pylint grades source, ruff grades tests, via a
`tests` basename ignore. Applying that reference config plus the existing
init-hook takes the four utils packages from 8.54-9.59 to 9.42-9.93, leaving
~47 genuine source findings instead of ~600 -- and music_theory's 10
import-errors look like the missing init-hook rather than code.

The done-condition is two commands with exit codes, verified to report
exactly the ten outstanding sites today.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kMvSMtsVMB3d2uoZ56pbp
2026-09-12 18:37:33 +02:00
8a556f8d7d Cache .mypy_cache so mypy stops re-analysing the stdlib every run
Profiled the 23s hook step per hook. It is not evenly spread: mypy ~10s and
pylint ~9s are the whole of it, and the remaining 21 hooks share ~4s. Local
timings with a warm cache put mypy at 0.25s against 5.7s cold, so nearly all
of its CI cost is re-analysing the stdlib and third-party stubs from scratch
into a 19MB cache dir that was then thrown away.

Keyed on the config rather than on the sources. The mypy cache metadata
already records the interpreter, the flag set and a hash per source file, so
mypy re-checks whatever actually changed and a restored cache cannot let
stale code pass. The config hash is in the key regardless, so bumping the
mypy rev or editing its args busts it.

Deliberately not keyed on github.sha, which is the other common pattern:
that re-saves 19MB x3 on every commit and would evict the 68MB hook caches
under the 10GB LRU budget for the repo. A fixed key keeps the dependency
analysis, which is the part that costs the 10s.

pylint needs no change -- it already runs --jobs=4.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kMvSMtsVMB3d2uoZ56pbp
2026-09-12 18:28:58 +02:00
a473e91485 Stop installing linters the pre-commit jobs never use, and add cache fallbacks
Two follow-ups measured on the warm-cache run of d56b936, where the three
pre-commit jobs were 39-44s split as: 4s runner setup, 9s pip, 2s cache
restore, 23s hooks.

The 9s pip was pure waste. Every linting hook runs in its own isolated env
-- ruff, mypy, pylint, bandit and codespell each come from their own
repo+rev, mypy and pylint declaring their own additional_dependencies -- and
the only local hooks in the pre-commit stage need bash and python3. The
pytest-coverage hook, the one thing that would need the real dependency set,
is stages: [pre-push] and never runs here. Verified by running all three
configs green in a venv containing pre-commit and nothing else. The pin is
grepped out of requirements.txt so it cannot drift from the
dependency-freshness gate.

restore-keys is added because the exact key includes the config hash, so the
next hook-rev bump -- this session did one -- would have been a total miss
and reinstalled everything. A prefix hit rebuilds only the changed hook.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kMvSMtsVMB3d2uoZ56pbp
2026-09-12 18:22:39 +02:00
4 changed files with 258 additions and 17 deletions

View File

@ -16,11 +16,17 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip
cache-dependency-path: crdt-sync/requirements.txt
- name: Install dependencies
working-directory: crdt-sync
run: pip install -r requirements.txt
# Only pre-commit itself. Every linting hook runs in its own isolated
# env -- ruff, mypy, pylint, bandit and codespell each come from their
# own repo+rev, and the local hooks need nothing beyond bash and
# python3 -- so installing the full requirements.txt spent 9s a run on
# packages no pre-commit-stage hook imports. Verified by running all
# three configs green in a venv holding pre-commit and nothing else.
# The pin is read out of requirements.txt rather than repeated here, so
# it cannot drift from what the dependency-freshness gate governs.
- name: Install pre-commit
run: |
pip install "$(grep '^pre-commit==' crdt-sync/requirements.txt)"
# Keyed on THIS package's config. pre-commit/action@v3.0.1 caches on
# hashFiles('.pre-commit-config.yaml') -- the repo ROOT's -- so all three
@ -34,6 +40,30 @@ jobs:
key: >-
pre-commit-crdt-sync-${{ env.pythonLocation }}-${{
hashFiles('crdt-sync/.pre-commit-config.yaml') }}
# Prefix fallback, or this fix would evaporate on the very
# event that motivated it: bumping a hook rev changes the
# exact key, and a total miss means reinstalling every hook
# again. pre-commit's store is keyed internally by hook
# repo+rev, so a superseded entry is ignored disk rather
# than a wrong hook, and cache still re-saves under the new
# exact key after a prefix-only hit.
restore-keys: pre-commit-crdt-sync-${{ env.pythonLocation }}-
# mypy re-analyses the stdlib and every third-party stub from scratch
# without this, which measured 10s of the hook step in CI against 0.25s
# warm locally -- a 19MB cache dir does the whole difference. Keyed on
# the config, not the sources: mypy's own cache metadata records the
# interpreter, the flag set and a hash per source file, so it re-checks
# what changed and cannot pass stale code. Deliberately NOT keyed on
# github.sha -- that re-saves 19MB x3 every commit and would evict the
# 68MB hook caches under the repo's 10GB LRU budget. A fixed key keeps
# the expensive part, the dependency analysis, which is what costs 10s.
- uses: actions/cache@v4
with:
path: .mypy_cache
key: >-
mypy-crdt-sync-${{ env.pythonLocation }}-${{
hashFiles('crdt-sync/.pre-commit-config.yaml') }}
restore-keys: mypy-crdt-sync-${{ env.pythonLocation }}-
- name: Run the hooks
run: >-
pre-commit run --config crdt-sync/.pre-commit-config.yaml

View File

@ -19,13 +19,17 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip
cache-dependency-path: freedays/requirements.txt
- name: Install the sibling package
run: pip install ./crdt-sync
- name: Install dependencies
working-directory: freedays
run: pip install -r requirements.txt
# Only pre-commit itself. Every linting hook runs in its own isolated
# env -- ruff, mypy, pylint, bandit and codespell each come from their
# own repo+rev, and the local hooks need nothing beyond bash and
# python3 -- so installing the full requirements.txt spent 9s a run on
# packages no pre-commit-stage hook imports. Verified by running all
# three configs green in a venv holding pre-commit and nothing else.
# The pin is read out of requirements.txt rather than repeated here, so
# it cannot drift from what the dependency-freshness gate governs.
- name: Install pre-commit
run: |
pip install "$(grep '^pre-commit==' freedays/requirements.txt)"
# Keyed on THIS package's config. pre-commit/action@v3.0.1 caches on
# hashFiles('.pre-commit-config.yaml') -- the repo ROOT's -- so all three
@ -39,6 +43,30 @@ jobs:
key: >-
pre-commit-freedays-${{ env.pythonLocation }}-${{
hashFiles('freedays/.pre-commit-config.yaml') }}
# Prefix fallback, or this fix would evaporate on the very
# event that motivated it: bumping a hook rev changes the
# exact key, and a total miss means reinstalling every hook
# again. pre-commit's store is keyed internally by hook
# repo+rev, so a superseded entry is ignored disk rather
# than a wrong hook, and cache still re-saves under the new
# exact key after a prefix-only hit.
restore-keys: pre-commit-freedays-${{ env.pythonLocation }}-
# mypy re-analyses the stdlib and every third-party stub from scratch
# without this, which measured 10s of the hook step in CI against 0.25s
# warm locally -- a 19MB cache dir does the whole difference. Keyed on
# the config, not the sources: mypy's own cache metadata records the
# interpreter, the flag set and a hash per source file, so it re-checks
# what changed and cannot pass stale code. Deliberately NOT keyed on
# github.sha -- that re-saves 19MB x3 every commit and would evict the
# 68MB hook caches under the repo's 10GB LRU budget. A fixed key keeps
# the expensive part, the dependency analysis, which is what costs 10s.
- uses: actions/cache@v4
with:
path: .mypy_cache
key: >-
mypy-freedays-${{ env.pythonLocation }}-${{
hashFiles('freedays/.pre-commit-config.yaml') }}
restore-keys: mypy-freedays-${{ env.pythonLocation }}-
- name: Run the hooks
run: >-
pre-commit run --config freedays/.pre-commit-config.yaml

View File

@ -18,11 +18,17 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip
cache-dependency-path: gatelock/requirements.txt
- name: Install dependencies
working-directory: gatelock
run: pip install -r requirements.txt
# Only pre-commit itself. Every linting hook runs in its own isolated
# env -- ruff, mypy, pylint, bandit and codespell each come from their
# own repo+rev, and the local hooks need nothing beyond bash and
# python3 -- so installing the full requirements.txt spent 9s a run on
# packages no pre-commit-stage hook imports. Verified by running all
# three configs green in a venv holding pre-commit and nothing else.
# The pin is read out of requirements.txt rather than repeated here, so
# it cannot drift from what the dependency-freshness gate governs.
- name: Install pre-commit
run: |
pip install "$(grep '^pre-commit==' gatelock/requirements.txt)"
# Keyed on THIS package's config. pre-commit/action@v3.0.1 caches on
# hashFiles('.pre-commit-config.yaml') -- the repo ROOT's -- so all three
@ -36,6 +42,30 @@ jobs:
key: >-
pre-commit-gatelock-${{ env.pythonLocation }}-${{
hashFiles('gatelock/.pre-commit-config.yaml') }}
# Prefix fallback, or this fix would evaporate on the very
# event that motivated it: bumping a hook rev changes the
# exact key, and a total miss means reinstalling every hook
# again. pre-commit's store is keyed internally by hook
# repo+rev, so a superseded entry is ignored disk rather
# than a wrong hook, and cache still re-saves under the new
# exact key after a prefix-only hit.
restore-keys: pre-commit-gatelock-${{ env.pythonLocation }}-
# mypy re-analyses the stdlib and every third-party stub from scratch
# without this, which measured 10s of the hook step in CI against 0.25s
# warm locally -- a 19MB cache dir does the whole difference. Keyed on
# the config, not the sources: mypy's own cache metadata records the
# interpreter, the flag set and a hash per source file, so it re-checks
# what changed and cannot pass stale code. Deliberately NOT keyed on
# github.sha -- that re-saves 19MB x3 every commit and would evict the
# 68MB hook caches under the repo's 10GB LRU budget. A fixed key keeps
# the expensive part, the dependency analysis, which is what costs 10s.
- uses: actions/cache@v4
with:
path: .mypy_cache
key: >-
mypy-gatelock-${{ env.pythonLocation }}-${{
hashFiles('gatelock/.pre-commit-config.yaml') }}
restore-keys: mypy-gatelock-${{ env.pythonLocation }}-
- name: Run the hooks
run: >-
pre-commit run --config gatelock/.pre-commit-config.yaml

View File

@ -0,0 +1,153 @@
# TODO — pylint `--fail-under=10` everywhere, and clear what that surfaces
REMOVE ME AFTER FINISH
## what
Ten pylint hooks across six repos still pass at `--fail-under=8.0`, which
permanently tolerates two points of lint debt and lets a score *regress* from
9.9 to 8.1 without failing anything. Move every one to `10`, and fix what
that surfaces. Five other sites already run at `10`, so this is adopting an
existing standard, not inventing one.
## the ten sites, exact
Measured 2026-09-12. "Score now" is that package's current rating under its
own config, tests included.
| Repo / package | Site | Score now |
|---|---|---|
| `control-panel` | `.pre-commit-config.yaml:159` | 8.53 |
| `leetcode-guard` | `.pre-commit-config.yaml:112` | 8.71 |
| `screen-locker` | `.pre-commit-config.yaml:121` | 9.85 |
| `screen-locker` | `.pre-commit-config.yaml:140` | (2nd pylint hook) |
| `steam-backlog-enforcer` | `.pre-commit-config.yaml:124` | 8.76 |
| `testsAndMisc/meta` | `.pre-commit-config.yaml:194` | 8.77 |
| `utils/crdt-sync` | `.pre-commit-config.yaml:111` | 9.59 |
| `utils/freedays` | `.pre-commit-config.yaml:109` | 8.55 |
| `utils/gatelock` | `.pre-commit-config.yaml:109` | 9.18 |
| `utils/music_theory` | `.pre-commit-config.yaml:113` | 8.54 |
`screen-locker` has **two** pylint hooks; both need the bump or the second one
silently keeps the old bar.
Already at `10` — do not touch, these are the reference:
`build-your-x`, `diet-guard`, `testsAndMisc` (root config),
`wake-alarm`, `WUT_Computer_Science/.../translator/.pylintrc`.
## why the scores look bad, and why that is misleading
Every one of these configs runs `enable = "all"` with `disable = []` — the
strictest pylint setting there is, including checks that are off by default.
The raw findings are dominated by **test-file idioms**, not source defects.
Measured on the four `utils` packages:
```
crdt-sync 54 protected-access, 50 redefined-outer-name, 18 duplicate-code
freedays 100 missing-function-docstring, 14 implicit-booleaness
gatelock 147 redefined-outer-name, 142 protected-access
music_theory 112 missing-function-docstring, 14 missing-module-docstring
```
`redefined-outer-name` at that volume is pytest fixtures. `protected-access`
is tests reaching into internals on purpose. Neither is a defect.
**The repos already at 10 solved this and wrote down why.** From
`wake-alarm/pyproject.toml`, verbatim:
> `ignore = [".venv", "__pycache__", "tests"]` — "tests" is a basename match:
> test suites intentionally use patterns (protected-access, magic-value
> comparisons) that don't apply to source code, matching testsAndMisc's
> pylint scope (tests are linted by ruff, not pylint there either).
So the fleet standard is: **pylint grades source, ruff grades tests.** The ten
sites above are the outliers that never adopted it. Their `ruff` config
already carries the equivalent test exemptions
(`"**/tests/**/*.py" = ["ARG", "D", "PLC0415", "PLR2004", "S101", "SLF001"]`),
so tests stay linted — by the tool that has the right rules for them.
## what is actually left after adopting the fleet config
Measured: `pylint --ignore=.venv,__pycache__,tests` plus wake-alarm's
three-item `disable` list, run over source files only.
| Package | Score | Remaining findings |
|---|---|---|
| `crdt-sync` | 9.93 | 5 wrong-import-position, 3 duplicate-code, 1 too-many-locals, 1 invalid-name |
| `freedays` | 9.63 | 3 import-error, 1 broad-exception-caught |
| `gatelock` | 9.88 | 6 missing-function-docstring, 4 wrong-import-position, 3 too-many-instance-attributes, 3 import-outside-toplevel, 2 broad-exception-caught, 1 each too-many-arguments / invalid-name / duplicate-code / disallowed-name / chained-comparison |
| `music_theory` | 9.42 | 10 import-error |
That is ~47 real findings across four packages, not the ~600 the raw run
suggests. **`import-error` is almost certainly config, not code**: every repo
already at 10 carries an `init-hook` the 8.0 repos lack —
```toml
init-hook = "import sys; sys.path.insert(0, '.')"
```
Try that first on `music_theory` and `freedays` before editing any import.
## must
- Every site at `--fail-under=10`. No `9.5`, no per-repo exception.
- Adopt the reference config from `wake-alarm` / `diet-guard`: the `tests`
basename ignore, the `init-hook`, and only then the residue fixes.
- Fix findings in source. Prefer the fix to the disable, every time.
- must not: add a `# pylint: disable=` comment, or extend `disable = [...]`
beyond wake-alarm's three implicit-booleaness entries, **without asking
kuhy first — every time, per `memories/code-quality.md`.** All seven
"unavoidable" disables in a past konbini-67 session were reverted.
- must not: exclude a source file from pylint to raise the score, or drop
`enable = "all"`.
- must not: touch the five sites already at `10`.
- optional: `duplicate-code` findings may be genuine shared-code candidates
for `utils`. Note them, do not force a refactor to hit the number.
## done
Both commands, from `~`:
```bash
# 1. no site left below 10 (cov-fail-under is coverage, not pylint)
! grep -rn --include=.pre-commit-config.yaml --include=.pylintrc \
-E 'fail-under=(8|9)' ~/src ~/praca_magisterska 2>/dev/null \
| grep -v cov-fail-under
# 2. every one of the nine packages passes its own pylint hook
for d in ~/src/control-panel ~/src/leetcode-guard ~/src/screen-locker \
~/src/steam-backlog-enforcer ~/src/testsAndMisc/meta \
~/src/utils/crdt-sync ~/src/utils/freedays \
~/src/utils/gatelock ~/src/utils/music_theory; do
(cd "$d" && pre-commit run pylint --all-files) || echo "FAIL $d"
done
```
Command 1 prints nothing and exits 0; command 2 prints no `FAIL` line.
## verify
Desktop. Per repo, `pre-commit run --all-files` must be green — not just the
pylint hook, since a fix that satisfies pylint can break `ruff`, `mypy` or the
250-line cap. Then the test suite: these are behaviour-affecting edits
(`broad-exception-caught` and `import-outside-toplevel` fixes especially), and
every one of these packages holds a 100% coverage bar.
`utils` and `testsAndMisc` each have CI; push and confirm green rather than
trusting the local run. `gatelock`'s Tk suite is flaky on a live X session —
run it under `xvfb-run -a` and compare against a baseline worktree before
blaming a change for a failure.
## read first
- `~/src/wake-alarm/pyproject.toml` — `[tool.pylint]`, the reference config.
`diet-guard` is byte-similar; `build-your-x` also ignores `conftest.py`.
- `~/.claude/memories/code-quality.md` — the suppression rule that governs
every `disable` decision in this task.
- `~/src/utils/rules/` is not involved; this is not a dependency change.
Each repo is its own git repo: commit per repo, work on `main`, stage
narrowly. `utils` additionally runs the shared `md-naming` and file-length
gates, so delete this file in that repo's final commit.
REMOVE ME AFTER FINISH