Skip to content

fix: stop writing bytecode caches in installs and the test suite - #16

Merged
SunsetDrifter merged 1 commit into
mainfrom
fix/no-bytecode-cache
Oct 8, 2026
Merged

SunsetDrifter merged 1 commit into
mainfrom
fix/no-bytecode-cache

Conversation

@SunsetDrifter

Copy link
Copy Markdown
Owner

Summary

Install bug: on any Python that writes bytecode (any normal 3.11+), each python3 lint.py ... run created wikilint/__pycache__/ inside the wiki. The template ships no .gitignore, so the agent's next git add -A would commit .pyc files into the wiki's history. Reproduced on a field-test install: ?? wikilint/__pycache__/ after a single lint run. lint.py now sets sys.dont_write_bytecode = True before importing the engine. Recompiling about 1,900 lines per run costs milliseconds, so the cache bought nothing.

Test hygiene: the suite wrote wiki/__pycache__/lint.*.pyc into the template through py_compile in test_everything_compiles. That directory then showed up as an "unknown top-level entry" warning when linting the template. The test now uses builtin compile(), which checks syntax without writing files, and tests/helpers.py turns off bytecode writes for the whole run.

Test plan

  • TDD: tests/test_no_bytecode.py written red first (a subprocess lint run in a copied install leaves no __pycache__; the suite runs with bytecode writes off; no py_compile in tests)
  • Suite passes on 3.11.14 and 3.14.4 (150 tests); the template has 0 __pycache__ dirs afterwards
  • Template lint back to baseline (0 errors, 2 warnings)
  • Field test: fresh install, lint, then commit through the pre-commit hook leaves a clean git status and no bytecode in git ls-files

Any lint run on a normal Python created wikilint/__pycache__/ in the
install. The template ships no .gitignore, so the agent's next
`git add -A` would commit bytecode into the wiki's history. lint.py now
sets sys.dont_write_bytecode before importing the engine; recompiling
~1,900 lines per run costs milliseconds.

The suite also littered the template: test_variants' py_compile wrote
wiki/__pycache__/lint.*.pyc, which then surfaced as an unknown top-level
entry when linting the template. It now uses builtin compile(), and
helpers.py disables bytecode writes for the whole run.
@SunsetDrifter
SunsetDrifter merged commit 5446fbf into main Oct 8, 2026
2 checks passed
@SunsetDrifter
SunsetDrifter deleted the fix/no-bytecode-cache branch October 8, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant