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
# Bad
from qgs._core import QgsMapLayer, QgsVectorLayer
from qgis._core import QgsApplication
# Good
from qgs.core import QgsMapLayer, QgsVectorLayer
from qgis.core import QgsApplication
QGS102
# Bad
import qgs._core.QgsVectorLayer as QgsVectorLayer
# Good
import qgs.core.QgsVectorLayer as QgsVectorLayer
QGS103
# Bad
from PyQt5.QtCore import pyqtSignal
# Good
from qgis.PyQt.QtCore import pyqtSignal
QGS104
# Bad
import PyQt5.QtCore.pyqtSignal as pyqtSignal
# Good
import qgis.PyQt.QtCore.pyqtSignal as pyqtSignal
QGS105
# Bad: iface passed as argument
def some_function(somearg, iface):
# do something with iface
# Good: iface imported
from qgis.utils import iface
def some_function(somearg):
# do something with iface
# in classFactory the passing is OK, since QGIS injects it
def classFactory(iface):
# preferably do not pass the iface to plugin
QGS106
# Bad
import gdal
import ogr
# Good
from osgeo import gdal
Metadata
Release files for flake8-qgis 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8_qgis-0.1.4.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_qgis-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.2 kB
Release files / flake8_qgis-0.1.4.tar.gz
| Download URL | flake8_qgis-0.1.4.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3b5b0fbd206014b8bc94536dbfc958e71f61fd87e202c1b576bd987b3d9376a
|
|
BLAKE2b-256 checksum How to use checksums |
4fb514b78f2b8118135f8b249b7cb5c99395a918e111707a98d4a48c620b4c1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
|
Release files / flake8_qgis-0.1.4-py3-none-any.whl
| Download URL | flake8_qgis-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7305653a974518e178f66b68d2528dc09af6657c8f985e45fe62a2a947df88db
|
|
BLAKE2b-256 checksum How to use checksums |
dfa40d1e1bebadacaf86f3ccb415ac8d351245ea5c7757df7ce081209659ef9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
|