pyCharm/PTVS type inference
Hello
I read article, http://habrahabr.ru/company/microsoft/blog/185412/ [RUS, screenshorts available] about Python Tools for Visual Studio. And I found that in code example PTVS have cool type inference.
So, question - why pyCharm can not do the same?
Thanks!
B7W
I read article, http://habrahabr.ru/company/microsoft/blog/185412/ [RUS, screenshorts available] about Python Tools for Visual Studio. And I found that in code example PTVS have cool type inference.
So, question - why pyCharm can not do the same?
def f(x): def g(y): return x + y return g a = f(1)(2) b = f(3.0)(a) c = f(u'a')(str(b)) d = (a, b, c)[input()]
Thanks!
B7W
1 comment
Sort by
Date
Votes
PyCharm uses different type inference algorithms. We experiment with type inference techniques using large Python projects as our playground. If a technique is able to infer a significant amount of types and it is lightweight, then we include it in our type inference algorithm. For example, PyCharm 3 is able to infer types of function parameters based on local usages, so the type of x in your example will be int | float | unicode. We don't track types of arguments in the context of a single function call yet for performance reasons. We will continue to work on our type inference in the future versions of PyCharm.
Please sign in to leave a comment.