Skip to content

Adjust location when parsing deferred type annotations#133

Merged
charliermarsh merged 1 commit intomainfrom
charlie/deferred
Sep 8, 2022
Merged

Adjust location when parsing deferred type annotations#133
charliermarsh merged 1 commit intomainfrom
charlie/deferred

Conversation

@charliermarsh
Copy link
Member

Resolves #132.

@charliermarsh charliermarsh merged commit c61ff9a into main Sep 8, 2022
@charliermarsh charliermarsh deleted the charlie/deferred branch September 8, 2022 15:37
Gankra added a commit that referenced this pull request Oct 14, 2025
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 #133
Gankra added a commit that referenced this pull request Oct 30, 2025
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 #133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint errors in forward-reference annotations always have a 1:1 location

1 participant