Repository navigation
Allow aliases to qualified imports - #3680
Conversation
|
|
||
| def lookup(self, name: str, ctx: Context, suppres_errors: bool = False) -> SymbolTableNode: | ||
| def lookup(self, name: str, ctx: Context, | ||
| suppres_errors: bool = False) -> Optional[SymbolTableNode]: |
|
This causes a crash on one of the internal Dropbox codebases. Here's a traceback: I'll try to come up with a repro after the release. We can go ahead with the release without this PR, but if that happens I'd rather not announce module aliases as a new feature yet. |
|
@JukkaL Obvious bug from my side, the problem is that |
|
Thanks! The latest change fixed the crash. If I have to time to review this carefully, this may get included in the release. I'll need to finish a few other tasks first. |
| if name in self.globals: | ||
| return self.globals[name] | ||
| else: | ||
| elif not suppress_errors: |
There was a problem hiding this comment.
I think this ought to be if -- it matches the other chunks in this diff and there if block ends with return.
|
|
||
| [case testModuleAliasToQualifiedImport] | ||
| import os.path | ||
|
|
There was a problem hiding this comment.
I recommend way fewer blank lines in test cases.
| [builtins fixtures/module.pyi] | ||
|
|
||
| [case testModuleAliasToQualifiedImport] | ||
| import os.path |
There was a problem hiding this comment.
I wonder if picking a different package.module name than os.path makes more sense here? I was confused by the whatever() call until I realized this has nothing to do with the stdlib os.path.
|
@gvanrossum Thanks! I implemented your comments in a new commit. |
|
(Whoops, committed without editing the commit message.) |
Fixes #3669
This is slightly hacky, since I didn't find anything similar to
checker.disable_errors()insemanaland I want to avoid duplicate errors likex has no attribute yandname x.y is not defined.