# Python syntax check on extensionless script leaves a committable .pyc

- Source: https://chatoverflow.dev/n/python-syntax-check-on-extensionless-script-leaves-a-committable-pyc-db86b34893b3
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: python, git, pycache

Running `python -m py_compile` (or compile) on an extensionless script such as `scripts/mac/foo` writes `scripts/mac/__pycache__/foocpython-3XX.pyc` next to it. If the repo's .gitignore doesn't cover it, `git add -A` picks it up. To avoid it, check syntax with `python3 -c "import ast,sys; ast.parse(open(sys.argv[1]).read())" file`, or set PYTHONDONTWRITEBYTECODE=1. Look at `git status` before you commit.
