Repository navigation
fix(core): warn once for renamed names served by lazy_exports - #5530
Merged
Merged
Conversation
A package facade built by lazy_exports resolved a name missing from its export table through a new moved_names_getattr getter on every access. Each getter starts with an empty record of warned names, so a from-import, which looks the name up more than once, warned twice, and every later attribute access warned again. Build the getter on first use and keep it, so each old name warns once, as it does for a module's own __getattr__. _moved_paths is still imported inside the function. Signed-off-by: Ananth Subramaniam <[email protected]>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
ananthsub
marked this pull request as ready for review
November 3, 2026 19:40
This was referenced Nov 3, 2026
This branch was previously 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.
What changed and why
Package facades such as
nemo_gym.configandnemo_gym.modelsbuild their__getattr__withlazy_exportsinnemo_gym/_public_api.py. A name missing from the package's export table falls back toMOVED_NAMESthroughmoved_names_getattr(package). That getter tracks the names it has already warned about in a set held by its closure, butlazy_exportsbuilt a new getter on every access, each with an empty set. So the deprecation warning repeated:from nemo_gym.config import TOKEN_ID_CAPTURE_BLOCKwarned twice, because a from-import looks the name up on the package more than once.nemo_gym.config.TOKEN_ID_CAPTURE_BLOCKaccess warned again.The fix builds the getter once per package, on the first fallback, and reuses it. Each old name now warns once, as it does when a module installs
moved_names_getattras its own__getattr__._public_apistill imports_moved_pathsinside the function, so its import edges don't change.No issue: this is a small follow-up to the package reorganization tracked in #5166. The duplicate warning showed up in #5528.
Tests
A new test in
tests/unit_tests/test_moved_paths.pyruns in a fresh interpreter. It records every warning, importsTOKEN_ID_CAPTURE_BLOCKfromnemo_gym.config(a name that package serves only throughMOVED_NAMES), then reads it again as an attribute, and checks that exactly one deprecation warning names the old path. On the code before this change it fails with three warnings.Validation
All pass.
Rollout evidence
N/A: only import-time deprecation warnings change. No environment, agent, or verifier behavior changes.
Compatibility
Code that imports a renamed name from a package facade now sees one deprecation warning instead of several. Once this and #5528 both land, the facade test in #5528 can tighten from "one distinct message" to "exactly one warning".