Skip to content

Accept relative imports #625

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

Merged
merged 2 commits into from
May 20, 2019
Merged

Accept relative imports #625

merged 2 commits into from
May 20, 2019

Conversation

r3m0t
Copy link
Contributor

@r3m0t r3m0t commented May 18, 2019

Two ways to do this:

  1. Resolve relative imports at compile time like this
  2. Defer to pyimport_importmodulelevelobject, so theoretically a package using entirely relative imports can be movied around so that it's importable under a different path.

I implemented the second, but it was excessively complicated and didn't provide any benefit, as I'm pretty sure the typechecking results rely on the module being under the usual path, so switched to this.

@r3m0t
Copy link
Contributor Author

r3m0t commented May 18, 2019

Closes #576

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

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

That seems like the right choice here to me, yeah.

This all seems solid. Thanks!

@msullivan msullivan merged commit 5d61f19 into mypyc:master May 20, 2019
@r3m0t r3m0t deleted the relative-imports-b branch May 21, 2019 06:48
msullivan pushed a commit to python/mypy that referenced this pull request Aug 20, 2019
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.

2 participants