Skip to content

Commit

Permalink
Merge pull request #34 from GispoCoding/update-lint-dependencies
Browse files Browse the repository at this point in the history
Upgrade development and linting dependencies
  • Loading branch information
LKajan authored Nov 18, 2023
2 parents 97ca84d + f94d6d8 commit 2a4e34b
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 50 deletions.
6 changes: 4 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# Black compatible values https://black.readthedocs.io/en/stable/compatible_configs.html#flake8
max-line-length = 88
extend-ignore =
E203, # whitespace before ':'
ANN101 # Missing type annotation for self in method
# E203: whitespace before ':'
E203,
# ANN101: Missing type annotation for self in method
ANN101
9 changes: 6 additions & 3 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: pip
- uses: pre-commit/[email protected]
12 changes: 9 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ jobs:
strategy:
matrix:
# Remove unsupported versions and add more versions. Use LTR version in the cov_tests job
docker_tags: [release-3_10, release-3_16, latest]
docker_tags: [release-3_28, latest]
fail-fast: false

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-python@v4
with:
cache: pip
- run: pip install pip-tools
- run: pip-compile requirements-dev.in

- name: Pull qgis
run: docker pull qgis/qgis:${{ matrix.docker_tags }}

Expand Down Expand Up @@ -62,7 +68,7 @@ jobs:
- name: Run tests
shell: pwsh
run: |
$env:PATH="C:\Program Files\QGIS 3.16\bin;$env:PATH"
$env:PATH=(Get-ChildItem -Path "C:\Program Files" -Directory QGIS*).FullName +"\bin;$env:PATH"
$env:QGIS_PLUGIN_IN_CI=1
python-qgis-ltr.bat -m pip install -qr requirements-dev.txt
python-qgis-ltr.bat -m pytest -v
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 21.7b0
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear~=21.4.3
- pep8-naming~=0.12.1
- flake8-qgis>=0.1.4
- flake8-bugbear~=23.9.16
- pep8-naming~=0.13.3
- flake8-qgis>=1.0.0
5 changes: 0 additions & 5 deletions .qgis-plugin-ci

This file was deleted.

34 changes: 16 additions & 18 deletions nlsgpkgloader/nls_geopackage_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self):

# Declare instance attributes
self.actions = []
self.menu = self.tr(u"&NLS GeoPackage Downloader")
self.menu = self.tr("&NLS GeoPackage Downloader")

# Check if plugin was started the first time in current QGIS session
# Must be set in initGui() to survive plugin reloads
Expand Down Expand Up @@ -200,7 +200,7 @@ def initGui(self): # noqa N802

self.add_action(
resources_path("icons", "icon.png"),
text=self.tr(u"NLS GeoPackage Downloader"),
text=self.tr("NLS GeoPackage Downloader"),
callback=self.run,
parent=self.iface.mainWindow(),
)
Expand All @@ -220,7 +220,7 @@ def _migrate_settings():
def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
for action in self.actions:
self.iface.removePluginMenu(self.tr(u"&NLS GeoPackage Downloader"), action)
self.iface.removePluginMenu(self.tr("&NLS GeoPackage Downloader"), action)
self.iface.removeToolBarIcon(action)

def run(self):
Expand Down Expand Up @@ -249,8 +249,8 @@ def run(self):
if not self.load_layers():
QMessageBox.critical(
self.iface.mainWindow(),
self.tr(u"Failed to load data"),
self.tr(u"Check that necessary files exist in data folder"),
self.tr("Failed to load data"),
self.tr("Check that necessary files exist in data folder"),
)
return

Expand Down Expand Up @@ -292,8 +292,8 @@ def run(self):
if self.fileName == "":
QMessageBox.critical(
self.iface.mainWindow(),
self.tr(u"Invalid filename"),
self.tr(u"Please enter a filename"),
self.tr("Invalid filename"),
self.tr("Please enter a filename"),
)
return
if self.fileName.split(".")[-1].lower() != "gpkg":
Expand Down Expand Up @@ -391,8 +391,8 @@ def run(self):
self.progress_dialog.hide()
QMessageBox.critical(
self.iface.mainWindow(),
self.tr(u"Invalid selection"),
self.tr(u"Found nothing to download!"),
self.tr("Invalid selection"),
self.tr("Found nothing to download!"),
)
return

Expand Down Expand Up @@ -673,7 +673,7 @@ def get_intersecting_features(self, features, layer, selected_mun_names=None):
if selected_mun_names:
expression = ""
for mun in selected_mun_names:
expression += u'"NAMEFIN" = \'' + mun + u"' OR "
expression += '"NAMEFIN" = \'' + mun + "' OR "
expression = expression[:-4]

iter = self.municipality_layer.getFeatures(expression)
Expand All @@ -694,7 +694,6 @@ def get_intersecting_features(self, features, layer, selected_mun_names=None):
self.utm25lr_features.append(layer_feature)

def download_data(self, product_types):

self.all_urls = []
self.total_download_count = 0
self.download_count = 0
Expand Down Expand Up @@ -858,9 +857,8 @@ def finish_processing(self):
)
)
self.iface.messageBar().pushMessage(
self.tr(u"GeoPackage creation finished"),
self.tr(u"NLS data download finished. Data located under ")
+ self.gpkg_path,
self.tr("GeoPackage creation finished"),
self.tr("NLS data download finished. Data located under ") + self.gpkg_path,
level=3,
)
self.progress_dialog.hide()
Expand All @@ -887,8 +885,8 @@ def show_settings_dialog(self):
# cannot work without the key, so user needs to be notified
QMessageBox.critical(
self.iface.mainWindow(),
self.tr(u"User-key is needed"),
self.tr(u"Data cannot be downloaded without the NLS key"),
self.tr("User-key is needed"),
self.tr("Data cannot be downloaded without the NLS key"),
)
return False
self.data_download_dir = (
Expand All @@ -903,8 +901,8 @@ def show_settings_dialog(self):
# cannot work without the key, so user needs to be notified
QMessageBox.critical(
self.iface.mainWindow(),
self.tr(u"User-key is needed"),
self.tr(u"Data cannot be downloaded without the NLS key"),
self.tr("User-key is needed"),
self.tr("Data cannot be downloaded without the NLS key"),
)
return False

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ testpaths = "tests"

[tool.coverage.report]
omit = ["nlsgpkgloader/qgis_plugin_tools/*"]

[tool.qgis-plugin-ci]
plugin_path = "nlsgpkgloader"
github_organization_slug = "GispoCoding"
project_slug = "NLSgpkgloader"
16 changes: 16 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pip-tools

# Testing
pytest
pytest-cov
pytest-qgis

# Linting and formatting
pre-commit
black
isort
flake8
flake8-bugbear
pep8-naming
flake8-qgis
PyQt5-stubs
128 changes: 116 additions & 12 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,117 @@
# Testing
pytest~=6.2.3
pytest-cov~=2.12.1
pytest-qgis~=0.1.0
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile '.\requirements-dev.in'
#
astor==0.8.1
# via flake8-qgis
attrs==23.1.0
# via flake8-bugbear
black==23.11.0
# via -r .\requirements-dev.in
build==1.0.3
# via pip-tools
cfgv==3.4.0
# via pre-commit
click==8.1.7
# via
# black
# pip-tools
colorama==0.4.6
# via
# build
# click
# pytest
coverage[toml]==7.3.2
# via
# coverage
# pytest-cov
distlib==0.3.7
# via virtualenv
exceptiongroup==1.1.3
# via pytest
filelock==3.13.1
# via virtualenv
flake8==6.1.0
# via
# -r .\requirements-dev.in
# flake8-bugbear
# flake8-qgis
# pep8-naming
flake8-bugbear==23.9.16
# via -r .\requirements-dev.in
flake8-qgis==1.0.0
# via -r .\requirements-dev.in
identify==2.5.31
# via pre-commit
importlib-metadata==6.8.0
# via build
iniconfig==2.0.0
# via pytest
isort==5.12.0
# via -r .\requirements-dev.in
mccabe==0.7.0
# via flake8
mypy-extensions==1.0.0
# via black
nodeenv==1.8.0
# via pre-commit
packaging==23.2
# via
# black
# build
# pytest
pathspec==0.11.2
# via black
pep8-naming==0.13.3
# via -r .\requirements-dev.in
pip-tools==7.3.0
# via -r .\requirements-dev.in
platformdirs==3.11.0
# via
# black
# virtualenv
pluggy==1.3.0
# via pytest
pre-commit==3.5.0
# via -r .\requirements-dev.in
pycodestyle==2.11.1
# via flake8
pyflakes==3.1.0
# via flake8
pyproject-hooks==1.0.0
# via build
pyqt5-stubs==5.15.6.0
# via -r .\requirements-dev.in
pytest==7.4.3
# via
# -r .\requirements-dev.in
# pytest-cov
# pytest-qgis
pytest-cov==4.1.0
# via -r .\requirements-dev.in
pytest-qgis==1.3.5
# via -r .\requirements-dev.in
pyyaml==6.0.1
# via pre-commit
tomli==2.0.1
# via
# black
# build
# coverage
# pip-tools
# pyproject-hooks
# pytest
typing-extensions==4.8.0
# via black
virtualenv==20.24.6
# via pre-commit
wheel==0.41.3
# via pip-tools
zipp==3.17.0
# via importlib-metadata

# Linting and formatting
pre-commit>=2.12.1
black~=21.7b0
isort~=5.9.3
flake8~=3.9.2
flake8-bugbear~=21.4.3
pep8-naming~=0.12.1
flake8-qgis>=0.1.4
# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools

0 comments on commit 2a4e34b

Please sign in to comment.