Found by a sweep while addressing Copilot's __dir__ comment on #428, which
raised the same class of issue against aorta/__init__.py. Filed rather than
folded into #428 because src/aorta/race/ is outside that PR's diff.
src/aorta/race/modes/__init__.py defers three exports behind a module-level
__getattr__ (PEP 562) and has no __dir__:
# Lazy imports to avoid circular dependencies
def __getattr__(name: str):
if name == "DefaultModeReproducer":
from .default import DefaultModeReproducer
return DefaultModeReproducer
...
__all__ = [
"create_reproducer",
"DefaultModeReproducer",
"DDPModeReproducer",
"FSDPModeReproducer",
]
So on a fresh import set(__all__) <= set(dir(aorta.race.modes)) is false:
three of the four promised names are absent from dir() until something has
already read them. Tab-completion and help() do not advertise them, which is
the introspection regression Copilot described on #428.
The repo already has an established form for this, in four modules:
def __dir__() -> list[str]:
return sorted(set(globals()) | set(__all__))
aorta/race/modes is the only module-level __getattr__ in src/ still
missing it.
What would close this
- Add the same
__dir__ to src/aorta/race/modes/__init__.py.
- A test asserting
set(__all__) <= set(dir(...)) on a fresh import in a
subprocess — in-process the pytest session has usually already resolved
the names, so the assertion passes vacuously. tests/test_package_version.py
has the pattern.
Low priority: this is introspection only, no import or runtime behaviour
changes.
Found by a sweep while addressing Copilot's
__dir__comment on #428, whichraised the same class of issue against
aorta/__init__.py. Filed rather thanfolded into #428 because
src/aorta/race/is outside that PR's diff.src/aorta/race/modes/__init__.pydefers three exports behind a module-level__getattr__(PEP 562) and has no__dir__:So on a fresh import
set(__all__) <= set(dir(aorta.race.modes))is false:three of the four promised names are absent from
dir()until something hasalready read them. Tab-completion and
help()do not advertise them, which isthe introspection regression Copilot described on #428.
The repo already has an established form for this, in four modules:
src/aorta/__init__.py(added in perf(cli): load command groups lazily, cuttingaorta --helpfrom 276 ms to 106 ms #428)src/aorta/report/__init__.pysrc/aorta/report/analysis/__init__.pysrc/aorta/report/generators/__init__.pyaorta/race/modesis the only module-level__getattr__insrc/stillmissing it.
What would close this
__dir__tosrc/aorta/race/modes/__init__.py.set(__all__) <= set(dir(...))on a fresh import in asubprocess — in-process the pytest session has usually already resolved
the names, so the assertion passes vacuously.
tests/test_package_version.pyhas the pattern.
Low priority: this is introspection only, no import or runtime behaviour
changes.