Code completion barely works

Say I'm working with the 'requests' python library.
req = requests.get("http://google.com")

Now after this, if I type 'req.', I'm supposed to get a list of all methods I can access. But for some reason I don't, even if I manually press ctrl-space.

If I try this in ipython, I get autocomplete recommendations. Even if I try it via the built in python console in pycharm, I get recommendations.

Why's this happening? I'm very underwhelmed by Pycharm because of this. Hope this isn't normal behavior.
3 comments
Python is a dynamically typed language, which means that the "get" function does not declare its return type. When you're entering code in IPython or in the PyCharm console, the code is actually being executed, and it's possible to inspect the object instance in the running interpreter and to get the list of its methods. When you're entering code in PyCharm or in any other Python IDE, it is not executed, and it's only possible to use static analysis to infer the return type of the method. This is not possible in all cases.
0
Also, please avoid cross-posting the same question to multiple forums.
0

this also happens even when the function returning the object can only create one type, pycharm knows this since during thath auto -completion I am shown the type that function will return, but then whether I assign the result of the function to a variable or follow up directly with a dot pycharm can't auto-complete that function.

for instance:

MySingletonClass.getInstance().someFunction()

or:

object = MySingletonClass.getInstance()

object.someFunction()

won't auto-complete someFunction().

even though this does work:

object = MyRegularClass()

object.someFunction()

does auto-complete someFunction().

pycharm can apparently keep track of the type of some objects but once instantiated like this don't get that treatment?

 

the dynamically typed argument goes out of the window when pycharm

  1. does know the return type of the function
  2. does know the type of a dynamic object if only it is instantiated in a different way.
0

Please sign in to leave a comment.