Skip to content

Add pet-hatch locator for Hatch-managed virtual environments#451

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-pet-hatch-locator
Draft

Add pet-hatch locator for Hatch-managed virtual environments#451
Copilot wants to merge 2 commits intomainfrom
copilot/add-pet-hatch-locator

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

Hatch environments contain a pyvenv.cfg, so PET previously classified them as plain Venv. Downstream consumers (e.g. vscode-python-environments) then routed them into the wrong manager collection.

Changes

  • New pet-hatch crate implementing the Locator trait, modeled on pet-uv / pet-virtualenvwrapper.
    • Resolves Hatch's virtual storage dir from HATCH_DATA_DIR, then platform defaults matching platformdirs.user_data_dir("hatch", appauthor=False) + env/virtual (Linux: $XDG_DATA_HOME/hatch/... or ~/.local/share/hatch/...; macOS: ~/Library/Application Support/hatch/...; Windows: %LOCALAPPDATA%\hatch\...).
    • try_from() claims a prefix as Hatch when it is either:
      1. Two components deep under the virtual storage dir (<storage>/<project-hash>/<env-name>), or
      2. Inside a project-local .hatch/<env-name>/ whose grandparent contains a hatch.toml or a [tool.hatch] / [tool.hatch.*] section in pyproject.toml.
    • Uses the pyvenv.cfg prompt for name; sets project_path for the project-local case.
    • find() walks the default storage dir and the configured workspace .hatch/ dirs.
  • Core enums: add Hatch to PythonEnvironmentKind and LocatorKind.
  • Locator chain (crates/pet/src/locators.rs): insert Hatch immediately before Venv so it claims first.
  • Refresh-contract test (crates/pet/src/jsonrpc.rs): register LocatorKind::Hatch as RefreshStatePersistence::ConfiguredOnly.

Notes for reviewers

  • For envs in the default storage layout, the project path cannot be reliably reverse-engineered from the <project-name>-<hash> directory name, so project_path is left None there. It is populated for the project-local .hatch/ case.
  • Project-local .hatch/ discovery requires a Hatch marker file in the workspace to avoid false positives on unrelated .hatch directories.
  • Identification of the default-storage layout is purely path-shape based (no marker required), matching how pet-uv and pet-poetry claim envs in their managed directories.

Copilot AI changed the title [WIP] Add Hatch environment detection with new pet-hatch locator Add pet-hatch locator for Hatch-managed virtual environments May 6, 2026
Copilot AI requested a review from eleanorjboyd May 6, 2026 16:05
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Test Coverage Report (Linux)

Metric Value
Current Coverage 76.6%
Base Branch Coverage 76.6%
Delta 0% ➖

Coverage unchanged.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Performance Report (macOS)

Metric PR (P50) PR (P95) Baseline (P50) Delta
Server Startup 56ms 496ms 103ms -47ms
Full Refresh 102ms 26519ms 175ms -73ms

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Performance Report (Linux) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 1ms 1ms 1ms 0ms 0%
Full Refresh 53ms 262ms 64ms -11ms -10.0%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Performance Report (Windows) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 9ms 12ms 11ms -2ms -18.2%
Full Refresh 146ms 3145ms 175ms -29ms -16.6%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Test Coverage Report (Windows)

Metric Value
Current Coverage 73.47%
Base Branch Coverage 73.55%
Delta -0.08% ❌

Coverage decreased. Please add tests for new code.

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.

Add Hatch environment detection (new pet-hatch locator)

2 participants