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: iface imported
from qgis.utils import iface
def some_function(somearg):
# do something with iface
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.2.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file flake8_qgis-0.1.2.tar.gz
.
File metadata
- Download URL: flake8_qgis-0.1.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2983af755a47643c05febdb2bec912b8db0cdd9a8be1ae41f0ab89f2fa3016a |
|
MD5 | 9204e3525feeb4108ef1ffb8829cf76a |
|
BLAKE2b-256 | d5574ddb52b8ae999a891b38844955dfeee33028c85500f5e2f0c9528b6f1476 |
File details
Details for the file flake8_qgis-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: flake8_qgis-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 267f797e21c348f5661abc122ec7b1fe9959e4d4d453fab09246571a0ac0b12b |
|
MD5 | d0b097dd661f4880b75050f025f0b709 |
|
BLAKE2b-256 | e999594eae70219ebdbf03755c288c4892141e06524fa5ff87796064cbccb8dc |