About Cognitive Code Complexity

One way to check the cognitive complexity of your code as for humans is using the complexipy package:

(venv)$ pip install complexipy
(venv)$ complexipy .

It will show you the list of checked files with their complexity evaluations:

  • Complexity ≤ 5: Simple, easy to understand.
  • Complexity 6-15: Moderate, acceptable for most cases.
  • Complexity > 15: Complex, consider refactoring into smaller functions.

Tips and Tricks Programming Developer Experience Python 3