Skip to content

fix(profiles): lazy-import pytest in descriptor_invariants_for (v26.4.2)#36

Merged
discreteds merged 1 commit into
mainfrom
hotfix/invariants-lazy-pytest-import
Apr 18, 2026
Merged

fix(profiles): lazy-import pytest in descriptor_invariants_for (v26.4.2)#36
discreteds merged 1 commit into
mainfrom
hotfix/invariants-lazy-pytest-import

Conversation

@discreteds

Copy link
Copy Markdown
Member

Summary

  • Moves import pytest from module-top of profiles/invariants.py into the body of descriptor_invariants_for.
  • Restores import mountainash_settings in any non-test env (downstream dev envs, production deploys).
  • Bumps version 26.4.1 → 26.4.2.

Root cause

profiles/__init__.py eagerly imports descriptor_invariants_for, which unconditionally did import pytest at module top. Any env without pytest installed crashed at import time. The settings test env has pytest, so the repo's own test run passed and masked the issue.

Surfaced while smoke-testing the v26.4.1 setattr fix against mountainash-data's dev hatch env — import mountainash_data blew up with ModuleNotFoundError: No module named 'pytest' during the transitive settings import.

Test plan

  • hatch run test:test tests/unit/ — 368/368 passing
  • Reviewer: confirm python -c "import mountainash_settings" works in a venv without pytest installed

Follow-ups (not in this PR)

  • main needs to be merged back into develop (develop is currently behind main at 9eba5bb)
  • Cut release/v26.4.2 from develop once main → develop merge happens

🤖 Generated with Claude Code

Module-top `import pytest` in profiles/invariants.py crashes any env
without pytest installed, because profiles/__init__.py eagerly imports
the helper. That meant `import mountainash_settings` failed in any
non-test env (downstream `dev` envs, production deploys).

Moves `import pytest` inside descriptor_invariants_for itself. The
helper still requires pytest to run, but merely importing
`mountainash_settings` no longer does.

Discovered while testing v26.4.1 setattr fix against
mountainash-data's dev env — settings test env has pytest so
`hatch run test:test` passed and masked the issue.

Bumps version 26.4.1 → 26.4.2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@discreteds discreteds merged commit 8946ed9 into main Apr 18, 2026
6 checks passed
@discreteds discreteds deleted the hotfix/invariants-lazy-pytest-import branch April 18, 2026 14:01
@codecov

codecov Bot commented Apr 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.90%. Comparing base (cd21af4) to head (3accd5f).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #36   +/-   ##
=======================================
  Coverage   96.90%   96.90%           
=======================================
  Files          31       31           
  Lines         841      841           
  Branches      109      109           
=======================================
  Hits          815      815           
  Misses         15       15           
  Partials       11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant