Skip to content

from .a.b import c in __init__.py(i) should define submodule attributes for *all* files #1490

@Gankra

Description

@Gankra

This is kind of a followup to astral-sh/ruff#21173 and pertains to behaviours described in imports/nonstandard_conventions.md

We do not currently consider from .a.b import c in an __init__.py(i) as ensuring thispackage.a.b or thispackage.a.b.c are submodule attributes in files that import thispackage, even though logically anything that acquires a reference to that module must have executed that import.

Ideally it should, but I think for safety it requires:

(This one may be a bad idea for performance/caching/isolation reasons, but I think it might be ok since we have to load and analyze that package's module anyway when you access an attribute on it?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    importsModule resolution, site-packages discovery, import-related diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions