Problem
.gitignore ignores __pycache__/ globally, but a later line re-includes everything under demos/:
__pycache__/
...
!demos/**
The !demos/** negation overrides the earlier __pycache__/ rule for that subtree, so running any demo (python demos/run_all.py) creates demos/__pycache__/*.pyc files that git status then reports as untracked/addable. A git add -A will happily commit compiled bytecode.
Repro
PYTHONUTF8=1 python demos/run_all.py
git status --short # shows demos/__pycache__/*.pyc as ??
git add -A && git status # bytecode is now staged
Suggested fix
Re-assert the ignore for bytecode after the negation, e.g.:
!demos/**
demos/**/__pycache__/
or scope the negation to source files only (!demos/**/*.py, !demos/**/*.json, !demos/**/*.md).
The .pyc files should never be part of the source tree; they are host/interpreter-version specific (cpython-314 here).
Problem
.gitignoreignores__pycache__/globally, but a later line re-includes everything underdemos/:The
!demos/**negation overrides the earlier__pycache__/rule for that subtree, so running any demo (python demos/run_all.py) createsdemos/__pycache__/*.pycfiles thatgit statusthen reports as untracked/addable. Agit add -Awill happily commit compiled bytecode.Repro
Suggested fix
Re-assert the ignore for bytecode after the negation, e.g.:
or scope the negation to source files only (
!demos/**/*.py,!demos/**/*.json,!demos/**/*.md).The
.pycfiles should never be part of the source tree; they are host/interpreter-version specific (cpython-314here).