Skip to content

chore: ignore and exclude local-only directories from Git, Ruff, and Black - #125

Merged
codeasier merged 1 commit into
mainfrom
chore/issue-119-ignore-local-dirs
Sep 17, 2026
Merged

codeasier merged 1 commit into
mainfrom
chore/issue-119-ignore-local-dirs

Conversation

@codeasier

Copy link
Copy Markdown
Owner

📝 Description

Two kinds of directories inevitably appear in a working checkout but were neither ignored by Git nor excluded from the linters:

  • .pt-snap/ — written into the current directory by pt-snap focus and pt-snap import (default focus update). Dogfooding from the repository root leaves an untracked focus.json containing machine-specific absolute paths that git add . would commit.
  • tmp/ — local scratch. On a real checkout this held 60+ unrelated scripts, and because Ruff/Black had no exclusions the documented root-level commands failed on them (ruff check . → 312 errors, black --check . → 66 files) while src tests benchmarks .github were completely clean.

Changes:

  • .gitignore: add .pt-snap/ (new "pt-snap runtime artifacts" section with a comment explaining where it comes from) and tmp/ (existing scratch section).
  • pyproject.toml: extend-exclude for both Ruff and Black covering .pt-snap, tmp, and the already-gitignored .tmp / .worktrees. Both tools honor .gitignore by default, so the explicit list is defensive: it keeps ruff check . stable under --no-respect-gitignore and makes the convention visible in the config rather than implied by .gitignore.
  • AGENTS.md: one paragraph under Development Commands documenting the convention.

No Python source or test changes.

🔗 Related Issue

Fixes #119

🧪 Testing

  • Tests added/updated — not applicable (configuration only)
  • Manual testing completed

Verified in the branch checkout after creating .pt-snap/focus.json, tmp/bad.py, .tmp/bad.py, and .pt-snap/bad.py (each with deliberate lint errors):

Check Result
git status --short only the three tracked modifications; no ?? .pt-snap/ / ?? tmp/
ruff check . All checks passed
ruff check . --no-respect-gitignore All checks passed (explicit excludes carry it)
black --check . 138 files would be left unchanged
Control: tests/_lint_canary.py with import os still reported by ruff check .
Control: same scratch files on main ruff check . reports the tmp/ errors

pytest tests/test_package.py tests/test_governance.py: 28 passed. pyproject.toml parses with tomllib.

✅ Checklist

  • Code follows project guidelines
  • Documentation updated (if applicable)
  • No new warnings introduced
  • Changes tested locally

Snapshot Runtime Provenance

  • Snapshot provenance evaluation completed when snapshot runtime files change
    Snapshot provenance decision: no-update
    Snapshot provenance no-update reason: This PR changes only .gitignore, pyproject.toml tool configuration, and AGENTS.md; no files under src/pt_snap_cli/snapshot/ are touched.

📋 Additional Notes

CI's lint job runs the same ruff check . / black --check . on a clean checkout, so its behavior is unchanged; the fix targets developer and agent checkouts that contain these local directories.

…Black

`pt-snap focus` and `pt-snap import` write `.pt-snap/focus.json` into the
current directory, so dogfooding from the repository root leaves an
untracked config file with machine-specific absolute paths that `git add .`
would commit. A local `tmp/` scratch directory has the same problem and,
because neither Ruff nor Black excluded it, made the documented root-level
`ruff check .` / `black --check .` fail on files that are not project
source while `src tests benchmarks .github` were clean.

Add `.pt-snap/` and `tmp/` to .gitignore and declare explicit
`extend-exclude` entries for both tools (including the already-ignored
`.tmp/` and `.worktrees/`) so the root-level commands behave the same as
the scoped ones even when gitignore handling is disabled. Document the
convention in AGENTS.md.

Fixes #119
@codeasier
codeasier merged commit 59f1aac into main Sep 17, 2026
6 checks passed
@codeasier
codeasier deleted the chore/issue-119-ignore-local-dirs branch October 3, 2026 19:18
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.

[FEATURE] .gitignore 与 ruff/black 排除规则覆盖本地工作目录(.pt-snap/、tmp/),避免根目录 lint 失败与误提交

1 participant