fix: preserve direct initializer bindings in package lookup

Merged
MA
4h ago
+121-0

Problem

A named lookup on a package called the initializer's complete get_attributes(). This expanded unrelated star imports even when the initializer already declared the requested binding. The equivalent public lookup on the initializer returned that binding directly.

This was identified while investigating flext-infra #3047. It is an independent lookup defect: Pydantic 2.14.4 publishes BaseModel through a star import, so this change alone does not establish a fix for that consumer's timeout.

Changes

  • Keep structural package attributes, including submodules and extensions, first.
  • Delegate other named queries to the initializer's existing get_attribute(), returning its original PyName.
  • Preserve namespace-package behavior, project-local invalidation, native errors and complete enumeration.
  • Add three public regression cases using real files. They cover explicit aliases, identity, submodule precedence, explicit bindings over star exports, star-only exports, namespace packages, and errors for dependent lookup and enumeration.
  • Add the numbered changelog fragment and record the producer/consumer qualification boundary in FORK-TRACKING.md.

Production changes only nine lines in PyPackage. No additional cache, suppression, compatibility alias or test-limit change is introduced.

Native validation

Test-only head b3f274b8aca19fbd48d5fefc7bd2f3b5fff50b40 was qualified at preview 565c9d183883c7112cbe176f95c7ee8aa96db0f4, whose tree exactly matched the authored tree 04f272c100ebe4da24c217b244c4c731c8228e2a.

Run 47665803364 reproduced exactly one failure in all four jobs:

Native jobPassedSkippedPassed subtestsDuration
Make and installed package35325626961.63 s
Linux35325626980.65 s
Windows352858270139.77 s
macOS353256269116.95 s

The initializer control resolved Public; the package query then raised ModuleSyntaxError for unrelated pkg/broken.py:1. Both other new cases passed. The native Make job completed source checks, documentation, build and 53 installed-wheel contracts before the expected source-suite failure.

Production head e588cd108a7adde264484e7e68dd1a3baee09acc passed run 47666344897. Preview 57dd2b67620054fae9d57eefb25da84c01afb4d9 has the exact authored tree 5d16f925e7aef122f2b6831119466befae1a7218 and unchanged base.

Qualified jobPassedSkippedPassed subtestsDuration
Make and installed package35335626961.11 s
Linux35335626994.56 s
Windows352958270123.25 s
macOS353356269102.86 s

All three new cases passed in every job. Native source checks, documentation, build and 53 installed-wheel contracts also passed. Black is green; there are no unresolved inline threads. The test inputs and assertions are unchanged from RED.

No project setup, tests, lint or generators were executed locally.

Consumer adoption and its original 2-second test budget remain separate pending evidence. No speedup is claimed.

Traceability

Revision 1.2 — 2026-12-06 — Marlon Costa marlon.costa@datacosmos.com.br — Datacosmos.

Base: 9f799f0f7be5c4ae9827ea22ce179d6737e22ffa. Existing LGPL-3.0-or-later license and copyright are preserved.