fix(profiles): lazy-import pytest in descriptor_invariants_for (v26.4.2)#36
Merged
Merged
Conversation
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>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
import pytestfrom module-top ofprofiles/invariants.pyinto the body ofdescriptor_invariants_for.import mountainash_settingsin any non-test env (downstreamdevenvs, production deploys).Root cause
profiles/__init__.pyeagerly importsdescriptor_invariants_for, which unconditionally didimport pytestat module top. Any env without pytest installed crashed at import time. The settingstestenv 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'sdevhatch env —import mountainash_datablew up withModuleNotFoundError: No module named 'pytest'during the transitive settings import.Test plan
hatch run test:test tests/unit/— 368/368 passingpython -c "import mountainash_settings"works in a venv without pytest installedFollow-ups (not in this PR)
mainneeds to be merged back intodevelop(develop is currently behind main at9eba5bb)release/v26.4.2from develop once main → develop merge happens🤖 Generated with Claude Code