mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 12:16:43 +00:00
This is a second take at the implicit imports approach, allowing `from . import submodule` in an `__init__.pyi` to create the `mypackage.submodule` attribute everyhere. This implementation operates inside of the available_submodule_attributes subsystem instead of as a re-export rule. The upside of this is we are no longer purely syntactic, and absolute from imports that happen to target submodules work (an intentional discussed deviation from pyright which demands a relative from import). Also we don't re-export functions or classes. The downside(?) of this is star imports no longer see these attributes (this may be either good or bad. I believe it's not a huge lift to make it work with star imports but it's some non-trivial reworking). I've also intentionally made `import mypackage.submodule` not trigger this rule although it's trivial to change that. I've tried to cover as many relevant cases as possible for discussion in the new test file I've added (there are some random overlaps with existing tests but trying to add them piecemeal felt confusing and weird, so I just made a dedicated file for this extension to the rules). Fixes https://github.com/astral-sh/ty/issues/133 <!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan <!-- How was it tested? --> |
||
|---|---|---|
| .. | ||
| basic.md | ||
| builtins.md | ||
| case_sensitive.md | ||
| conditional.md | ||
| conflicts.md | ||
| conventions.md | ||
| cyclic.md | ||
| dunder_all.md | ||
| errors.md | ||
| invalid_syntax.md | ||
| legacy_namespace.md | ||
| module_getattr.md | ||
| namespace.md | ||
| nonstandard_conventions.md | ||
| partial_stub_packages.md | ||
| relative.md | ||
| site_packages_discovery.md | ||
| star.md | ||
| stub_packages.md | ||
| stubs.md | ||
| tracking.md | ||