Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid extra . in from .. import parent imports in Rust Python dep inference #19175

Merged
merged 2 commits into from May 28, 2023

Conversation

huonw
Copy link
Contributor

@huonw huonw commented May 27, 2023

This fixes #19173 by generalising the from . import a special case to also handle from .. import a etc.: any module path that ends with a . doesn't need an extra . to separate the module path from the name(s).

Before this fix, from . import a was special cased to avoid an extra dot (becoming .a as desired), while from .. import a was not special cased. It became ...a (extra .), by joining the module path (..) and the name (a) with the usual . separator. This separator is only appropriate for normal names like from x import a.

@huonw huonw added needs-cherrypick category:bugfix Bug fixes for released features labels May 27, 2023
@huonw huonw added this to the 2.17.x milestone May 27, 2023
@huonw huonw requested review from stuhood and thejcannon May 27, 2023 11:16
Copy link
Member

@thejcannon thejcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Thanks!

@huonw huonw merged commit fedd4b5 into pantsbuild:main May 28, 2023
25 checks passed
@huonw huonw deleted the bugfix/19173-parent-imports-rust branch May 28, 2023 00:32
github-actions bot pushed a commit that referenced this pull request May 28, 2023
… inference (#19175)

This fixes #19173 by generalising the `from . import a` special case to
also handle `from .. import a` etc.: _any_ module path that ends with a
`.` doesn't need an extra `.` to separate the module path from the
name(s).

Before this fix, `from . import a` was special cased to avoid an extra
dot (becoming `.a` as desired), while `from .. import a` was not special
cased. It became `...a` (extra `.`), by joining the module path (`..`)
and the name (`a`) with the usual `.` separator. This separator is only
appropriate for normal names like `from x import a`.
huonw added a commit that referenced this pull request May 28, 2023
… inference (Cherry-pick of #19175) (#19177)

This fixes #19173 by generalising the `from . import a` special case to
also handle `from .. import a` etc.: _any_ module path that ends with a
`.` doesn't need an extra `.` to separate the module path from the
name(s).

Before this fix, `from . import a` was special cased to avoid an extra
dot (becoming `.a` as desired), while `from .. import a` was not special
cased. It became `...a` (extra `.`), by joining the module path (`..`)
and the name (`a`) with the usual `.` separator. This separator is only
appropriate for normal names like `from x import a`.

Co-authored-by: Huon Wilson <huon@exoflare.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"cannot infer owners" warning for from .. import foo with Rust parser
3 participants