I'm using PyCharm for some months now, and it's without a doubt the best Python IDE I've ever used!
With that being said, it's still has some flaws regarding code completion (well, naturally because of the dynamic typing system of Python).
In PyCharm 2.7, if I remember correctly, you introduced a feature for collecting run-time types information for code insight, which is used with the debugger. This is a great feature, but I think, it can be improved significantly.
This tool, in its current implementation, is used to collect type information only for parameters passed to a function, and for parameters returned from a function, but nothing else.
i.e. if there is a variable that is assigned to some object, which was dynamically created, then it seems that typing information will not be collected for it.
Let me show you an example, using sqlalchemy (which is the main reason that got me to write this post):
let's take a look at a simple database definition using SQLAlchemy's SQL Expression Language:
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, MetaData
engine = create_engine('sqlite:///:memory:')
metadata = MetaData()
table = Table('some_table', metadata, Column('some_col', Integer, primary_key=True))
ins = table.insert()
Now, if we take a look at the last line, 'ins' is a variable pointing to an Insert object, which has a lot of methods. We could say for example:
But there are no code completion suggestions for this variable, since the static type inference could not infer its type (you may want to take a look at the insert() method definition to understand why).
But, if I enable 'Collect run-time types information for code insight' in the 'Python Debugger' settings, I would expect that when I run the debugger, the type information for the variable 'ins' will be stored, and I will have code completion suggestions. However, that's not what happens.
But if I change this last line, into the following few lines:
ins = foo(table.insert())
And then run the debugger, the type information for the parameter 'a' will be collected, and since 'a' is also returned, I will also get typing information for 'ins' variable.
That's pretty weird behavior...
I would appreciate if you'll consider changing that behavior , and also collect type information for variables not part of a function parameters.