Menu

#1316 Local imports do not work for code completion type hinting

open
5
2011-04-14
2011-04-14
Ryan Seiff
No

Using assert isinstance(X, Y) does not work for a type Y that was imported into a local scope. For example, the following does not give the variable "param" code complete options:

def foo(param):
import weakref
assert isinstance(param, weakref.ReferenceType)
param.

To contrast, the following DOES work:

import weakref
def foo(param):
assert isinstance(param, weakref.ReferenceType)
param.

It is expected that both code blocks above cause code completion to work.

Discussion