You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolve wildcard imports via __all__ or public-names rule (#126)
`from pkg import *` is now desugared at analysis time against the target
package's exports, so names reached via wildcard — including those
re-exported through __init__.py — appear as concrete edges instead of as
spurious *.* residue at the importer's module level.
Export determination:
- Literal __all__ = ["a", "b"] (list or tuple, string elements only) is
authoritative, including leading-underscore names if listed.
- Absent __all__: public-names rule — every module-scope binding whose
identifier does not start with underscore.
- Non-literal forms (augmented assignment, dynamic construction) fall back
to the public-names rule with a debug log.
Implementation:
- New self.module_all dict populated from AST by _extract_dunder_all.
- New _module_public_exports helper with short-name → FQ-name candidate
resolution, mirroring _record_import.
- visit_ImportFrom desugars wildcard aliases against the export set
before the per-name binding loop.
- New prescan phase in CallGraphVisitor.process populates scopes and
__all__ for every input file before pass 1, making wildcard desugaring
order-independent (consumers of a wildcard import no longer need to
appear after the exporting package in the filename list).
Version bumped to 2.5.0-dev — this is a new-feature change, not a patch.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,14 @@
1
1
# Changelog
2
2
3
-
## 2.4.4 (in progress)
3
+
## 2.5.0 (in progress)
4
4
5
-
*No user-visible changes yet.*
5
+
### New features
6
+
7
+
-**Wildcard imports now resolve to actual targets.**`from pkg import *` is desugared at analysis time against the target package's `__all__` when declared as a literal list/tuple of strings, and against the public-names rule (every module-scope name not starting with `_`) otherwise. Names reached via wildcard — including those re-exported through `__init__.py` — now appear as concrete edges in the call graph instead of as spurious `*.*` residue at the importer's module level. Non-literal `__all__` forms (augmented assignment, dynamic construction) fall back to the public-names rule with a debug log. (#126)
8
+
9
+
### Internal
10
+
11
+
-**Prescan phase added before the two visitor passes.**`CallGraphVisitor.process` now does a lightweight scope + `__all__` walk over every input file up front, so cross-module metadata is fully populated before pass 1. This makes wildcard desugaring order-independent — the consumer of a wildcard import no longer has to appear after the exporting package in the filename list.
0 commit comments