Flake8 plugin for QGIS python plugins.
Project description
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 projected members (example)QGS102
: Don't use imports from qgis projected 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)
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
# Good
from qgs.core import QgsMapLayer, QgsVectorLayer
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
from qgis.utils import iface
def some_function(somearg):
# iface imported
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flake8_qgis-0.1.1.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for flake8_qgis-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13c675e790b6ca9ab12a89b66bbf243df3a9b6c2533b416c9286733f1c0cfcaf |
|
MD5 | 8bfc2aa5db8249c791c0ab83e975b949 |
|
BLAKE2b-256 | 9ff49c668b84aad6832c0a981f93328dfad0762e4dbf7df3dfc3ac23ab013308 |