[rntuple] Fix the circular import when rootfilespec.rntuple is imported first - #126
Open
sathabbott wants to merge 2 commits into
Open
sathabbott wants to merge 2 commits into
sathabbott wants to merge 2 commits into
Conversation
Importing any rootfilespec.rntuple module before rootfilespec.bootstrap failed with a circular import: rntuple.envelope imports bootstrap.compression, which runs bootstrap/__init__, which imports RAnchor, which imported the half-initialized rntuple.envelope. RAnchor only needs the rntuple names inside header_locator, footer_locator, get_header and get_footer, so import them there (and under TYPE_CHECKING for the annotations). tests/test_imports.py imports every module in a fresh interpreter. rootfilespec.container has the same kind of cycle through bootstrap.array and is marked as a strict expected failure. Fixes nsmith-#119 Assisted-by: claude-code:claude-opus-5-5
The repository's pinned ruff (0.9.2, pre-commit) does not enable PLC0415, so it reports these as unused noqa directives (RUF100). Assisted-by: claude-code:claude-opus-5-5
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #126 +/- ##
=======================================
Coverage 91.82% 91.83%
=======================================
Files 37 37
Lines 2962 2964 +2
=======================================
+ Hits 2720 2722 +2
Misses 242 242 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
Go ahead and fix the other case |
This branch has not been deployed
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.
Fixes #119.
import rootfilespec.rntuple.schema(or anyrootfilespec.rntuple.*module) in a fresh interpreter failed:rntuple.envelopeimportsbootstrap.compression, which runsbootstrap/__init__.py, which importsRAnchor, which imported the half-initializedrntuple.envelope.RAnchoronly needsREnvelopeLocator,HeaderEnvelope,FooterEnvelopeandLargeLocatorinsideheader_locator,footer_locator,get_headerandget_footer, so they are now imported there, and underTYPE_CHECKINGfor the annotations. No behaviour change.Test:
tests/test_imports.pyimports every module of the package in its own interpreter (35 modules). Onmain, all therntuplemodules fail.Found along the way, not fixed here:
rootfilespec.containerhas the same kind of cycle (container→bootstrap/__init__→bootstrap.array→container). It is markedxfail(strict=True)in the new test, so it will flag when fixed. Happy to fix it here or in a follow-up if you'd like; it isn't RNTuple, so I left it.Full suite:
389 passed, 53 skipped, 47 xfailed.Assisted-by: claude-code:claude-opus-5-5