flake8-qgis
A flake8 plugin for QGIS3 python plugins written in Python.
Made with Cookiecutter template cookiecutter-flake8-plugin.
Inspired by flake8-simplify.
Installation
Install with pip
:
pip install flake8-qgis
Usage
Just call flake8 .
in your package or flake your.py
.
Rules
QGS101
: Don't use from-imports from qgis protected members (example)QGS102
: Don't use imports from qgis protected members (example)QGS103
: Don't use from-imports from PyQt directly (example)QGS104
: Don't use imports from PyQt directly (example)QGS105
: Don't pass QgisInterface as an argument (example)QGS106
: Don't import gdal directly, import if from osgeo package (example)
You might have good reasons to ignore some rules.
To do that, use the standard Flake8 configuration. For example, within the setup.cfg
file:
[flake8]
ignore = QGS101, QGS102
Examples
QGS101
from qgs._core import QgsMapLayer, QgsVectorLayer
from qgis._core import QgsApplication
from qgs.core import QgsMapLayer, QgsVectorLayer
from qgis.core import QgsApplication
QGS102
import qgs._core.QgsVectorLayer as QgsVectorLayer
import qgs.core.QgsVectorLayer as QgsVectorLayer
QGS103
from PyQt5.QtCore import pyqtSignal
from qgis.PyQt.QtCore import pyqtSignal
QGS104
import PyQt5.QtCore.pyqtSignal as pyqtSignal
import qgis.PyQt.QtCore.pyqtSignal as pyqtSignal
QGS105
def some_function(somearg, iface):
from qgis.utils import iface
def some_function(somearg):
def classFactory(iface):
QGS106
import gdal
import ogr
from osgeo import gdal