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

add support for relative imports #2

Merged
merged 1 commit into from
Aug 5, 2013
Merged

Conversation

zzzeek
Copy link
Contributor

@zzzeek zzzeek commented Aug 5, 2013

per pep 328, relative imports add the ability to alter an import based on a "level" counter, which syntactically is a number of dots. With these changes I've managed to produce successful graphs for parts of SQLAlchemy (which uses all relative imports) without any errors. I've updated the tests though there should probably be some tests that test specifically the path resolution against the "sample-tree" package.

…rs to the number

of preceding dots on a "from ..xyz import qpr" relative import statement.
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling de437a7 on zzzeek:master into 8c4c399 on mgedmin:master.

@mgedmin
Copy link
Owner

mgedmin commented Aug 5, 2013

Awesome, thanks!

"""Given a fully qualified name, find what module contains it."""
if dotted_name.endswith('.*'):
return dotted_name[:-2]
name = dotted_name

orig_extrapath = extrapath
Copy link
Owner

Choose a reason for hiding this comment

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

You're introducing a new local variable here, but it doesn't seem to be used anywhere...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that's a goof, you can take that out...

mgedmin added a commit that referenced this pull request Aug 5, 2013
add support for relative imports (from . import X)
@mgedmin mgedmin merged commit 2d44715 into mgedmin:master Aug 5, 2013
@mgedmin
Copy link
Owner

mgedmin commented Aug 5, 2013

Looks good, merged, thanks again!

@mgedmin
Copy link
Owner

mgedmin commented Aug 5, 2013

Bikeshedding: is this a feature ("add support for relative import syntax introduced in Python 2.somethingprettyoldbynow") or a bugfix ("findimports didn't understand relative import syntax introduced in Python 2.somethingprettyoldbynow")? Because if it's a feature, then I ought to bump the version number to 1.4.0.

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.

3 participants