Check and improve code quality and complexity

If the quality of software is neglected, this quickly leads to superfluous code, also known as cruft. This then slows down the further development of functions. This also happens to great teams who are not allowed to spend time maintaining high code quality. High code quality reduces cruft to a minimum and allows the team to add features with less effort, time and cost. Although there are some indicators that can be used to measure internal quality, these can only provide an initial indication of further productivity. However, a recent study indicates that low quality code took more than twice as long to fix as high quality code, and that low quality code had a 15 times higher defect density.

In the following, I will show you some Code-Smells and design principles and then some tools with which you can perform automated static analyses and reformat the code. You can integrate some of these tools into your editor as well as via the pre-commit framework. Finally, I’ll introduce you to Rope, a tool that supports you with refactorings.



is a wrapper around PyFlakes, pycodestyle and McCabe. However, automatic formatting, for example with Black, is even more convenient.


is a static type checker.


is a static analysis tool that derives types from your Python code without the need for type annotations.


is a command line tool for checking the complexity of Python code in tests and applications.


analyses the structural reliability of Python code and summarises it in a report.


performs taint analysis to identify potential security problems. Pysa traces data streams from their origin to their endpoint and identifies vulnerable code.


is a tool with which you can quickly check whether the file for Python packages is complete.



formats your code in a nice and deterministic format.


formats your import statements in separate and sorted blocks.


offers automatic formatters for other file types.



is a Python refactoring library.