- There are, in total, three possible levels of severity indicated in the top-right corner of the editor: errors (), warnings (), and nothing detected (). It is generally good practice to address any problems in your code if the severity is either error or warning before using it or committing it to GitHub.
- Some of the most common problems in Python code detected by PyCharm are dead code, unused declarations, unresolved references, and PEP 8 style suggestions. Each of these problems can be addressed with various simple and convenient commands in PyCharm.
- The approach of code completion support from JetBrains' products in general, and not just PyCharm, is smart code completion, which only looks for the most applicable and most likely APIs to suggest in the pop-up list. Additionally, the logic that's used by code completion in PyCharm can be customized by users so that they have particular behaviors that fit individual needs.
Finally, JetBrains always looks to improve its code completion logic by collecting data regarding runtime types, if allowed by users. This allows PyCharm's code completion to be always evolving and accommodate the changing needs of Python programmers.
- The following are common code completion options in PyCharm that can prove useful for Python programmers:
- Smart code completion: Suggests the most applicable APIs in the pop-up list.
- Postfix code completion: Helps programmers correctly format various expressions without having to move their caret back and forth.
- Hippie completion: Suggests the items that are in the visible scope and context.
- Intention: Allows complex transformations after code has already been written. This feature can also be used outside the context of code completion.
- Common cases in which code completion support from PyCharm does not work are listed here:
- Running indexing: Wait until the indexing process is complete before using any code completion features.
- Power-save mode: Go to File > Power Save Mode to turn it off if your PyCharm is in power-save mode, which prevents code completion from working.
- Out-of-scope files: Move external files and scripts into the current project to have them scanned by PyCharm, or include external libraries in requirements.txt.
- In PyCharm, programmers can perform the following refactoring tasks via convenient shortcuts:
- Renaming: This includes variables, functions, classes, methods, and even files. PyCharm takes care of the renaming in all locations where the name to be changed is used.
- Extracting methods: This is used to move a specific block of code outside the current scope and convert it into a function or method. All of the parameters and return types for the function/method are automatically generated by PyCharm.
- Converting between methods and functions: This allows users to change a class method into a function outside the scope of the class, and vice versa. All calls to the new function are handled and converted accordingly as well.
- Three main aspects of working with Python documentation in PyCharm are listed here:
- Creating documentation: This is done when a pair of triple-double quotes are expanded into multiple lines. A Python docstring template is used to generate specific formats for documentation created in this way.
- Customizing docstring format: To change the way the default docstring is generated in the aforementioned process, you can go to Tools > Python Integrated Tools in PyCharm's general settings.
- Viewing documentation: Quick Documentation and Quick Definition can be used to dynamically view the documentation and definition of a specific API in PyCharm. This can be applied to built-in functions, external packages and libraries, as well as self-written functions, classes, and methods.