Skip to content

Standard .gitignore baseline should exclude Python bytecode (__pycache__/, *.pyc) #1081

Description

@don-petry

Problem

The org baseline .gitignore (seeded into repos from repo-template) does not exclude Python bytecode. When an agent workflow runs the test suite and then commits the working tree, it silently commits compiled bytecode.

Observed concretely: in petry-projects/incubator#121, dev-lead ran pytest while fixing review comments and committed 11 __pycache__/*.pyc files (pocs/demand-radar/__pycache__/*.cpython-312.pyc and the pytest-cache .pycs under tests/__pycache__/). No reviewer or agent caught it because it's the agent's own byproduct, and nothing in .gitignore prevents it.

This will recur on any Python-touching repo where an agent (or a human running tests) commits broadly — bytecode is non-deterministic noise that bloats diffs and can leak local paths/versions.

Proposal

Add Python bytecode patterns to the standard baseline .gitignore (and/or the backend-python / fullstack stack variants under standards/):

# Python bytecode & caches
__pycache__/
*.py[cod]
.pytest_cache/

Rationale:

  • __pycache__/ + *.py[cod] covers .pyc/.pyo/.pyd.
  • .pytest_cache/ covers pytest's own cache dir.
  • These are universally safe to ignore (always regenerable), so seeding them fleet-wide has no downside.

Acceptance

  • Baseline .gitignore (and Python stack variants) include the patterns above.
  • A fresh repo from repo-template no longer lets a pytest run's bytecode be committed.

Filed from work on petry-projects/incubator#121, where the gap surfaced.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions