[FIXED] Pycharm Code Completion does not work in methods or functions

Issue

This is so weird... Code completion only works outside a method... Anyone know how to fix this?

src="https://i.stack.imgur.com/WFJPq.png" alt="enter image description here" />

enter image description here


Solution

This is the way it should work, and it has nothing to do with being inside or outside a method or function.

Your function does not have type hints (type annotations generally speaking), so Pycharm's type checker can't infer the type of text, and it assigns the Any type to texts.

enter image description here

Instead, if you put a type hint like text: str, then texts will be treated like a List[str]:

enter image description here

and Pycharm's autocomplete will show its methods:

enter image description here



Answered By - Jonathan Ciapetti
Answer Checked By - Mildred Charles (Python.Easybugfix Admin)

Related Posts

Post a Comment