No autocompletion for a created type


def enum(*sequential, **named):
    enums = dict(zip(sequential, range(len(sequential))), **named)
    return type('Enum', (), enums)

Level. -> No autocompletion


Zooba wrote Mar 17 at 3:52 PM

Good catch, though I wouldn't hold your breath on this being supported.

Our code analysis is based on types, and this code snippet requires us to handle specific values. The reason we focus on types is because otherwise trivial code becomes infinitely recursive:
def f(x):
    return f(x + 1)
Right now we see that x is int, x + 1 is int, and so we don't need to replay the recursion.

If we saw that x is 0 and x + 1 is 1, we'd need to reanalyze f with the new value, just in case it later ends up appearing in completions. Obviously, this gets out of hand extremely quickly :)

Your example code is even harder to handle - we'd need to support zip, dict and type in far more detail than currently. A more likely solution is that we will support standard enums (just released in Python 3.4) and maybe eventually a simple way to extend our analyzer to handle these sort of types. (The latter is already possible, incidentally, though it is far from simple.)