Qodana for Python
Qodana Python is based on PyCharm Professional and provides static analysis for Python projects.
Try it now
Analyze a project locally
To start, pull the image from Docker Hub (only necessary to get the latest version):
For a basic Python project, which only uses stdlib
, no preliminary steps are required.
In case a project has external pypi
dependencies, use any of the following options:
Create
virtualenv
as a subfolder in your project and exclude it in qodana.yaml to skip analysis of vendor code.Mount a separate
virtualenv
as cache.When you create the
virtualenv
folder, no actualpython
binary is copied into it. Instead, a symlink is created topython
binary used to create virtualenv. This could lead to incorrect paths when yourvirtualenv
is being read inside the Qodana container, sincepython
location there could be different. To fix this, createvirtualenv
using the Qodana container'spython
:docker run --rm \ -v <source-directory>/:/data/project/ \ -v <cache-directory>/:/data/cache/ \ --entrypoint=bash \ jetbrains/qodana-python -c ' python3 -m venv /data/cache/venv source /data/cache/venv/bin/activate pip3 install -r /data/project/requirements.txt '
The project dependencies are now stored in <cache-directory>
. This folder could be preserved between builds to speed them up.
Start local analysis with cache mounted and with source-directory
pointing to the root of your project, and it would automatically look for virtualenv
in /data/cache/venv
:
This command will run the analysis on your source code and start the web server to provide a convenient view of the results. Open http://localhost:8080
in your browser to examine the found problems and performed checks. Here you can also reconfigure the analysis. See the User interface overview for details. When done, you can stop the web server by pressing Ctrl-C in the Docker console.