-
Notifications
You must be signed in to change notification settings - Fork 179
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
Importation classes with imported name and alias #54
Conversation
Note that I have a functionally equivalent changeset which does all the work within the existing |
@bitglue , could you please review this. I have pending changes that depend on this. |
Looks good on a brief read. I'll take a deeper look tonight. |
This looks good. Can you please rebase onto master? |
# A dot should only appear in the name when it is a submodule import | ||
# without an 'as' clause, which is a special type of import where the | ||
# root module is implicitly imported, and the submodules are also | ||
# imported by Python does not restrict which attributes of the root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, just noticed : 'by' should be 'but' or 'however'
In order to solve many corner cases related to imports, more information is needed about each import. This change creates two new classes: - SubmoduleImportation - ImportationFrom And adds an optional parameter full_name to the super class Importation. Functionally, this change only improves existing error messages to report the full imported name where previously an error would include only the import alias.
def __str__(self): | ||
"""Return import full name with alias.""" | ||
if self._has_alias(): | ||
return self.fullName + ' as ' + self.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would we prefer %s
syntax here instead of +
? It does seem that %s syntax is preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any particular preference.
This appears to break relative imports like: |
Yea, there were no tests covering them, and I forgot about those. The fix #61 is waiting for review. |
In order to solve many corner cases related to imports,
more information is needed about each import.
This change creates two new classes:
And adds an optional parameter full_name to the super class
Importation.
Functionally, this change only improves existing error messages
to report the full imported name where previously an error
would include only the import alias.