diff --git a/.flake8 b/.flake8 index 24415d2..0c4d533 100644 --- a/.flake8 +++ b/.flake8 @@ -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 diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 2770d91..4fc33f9 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -9,6 +9,9 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.9" + cache: pip + - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e90992e..6d5e8aa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 }} @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 02822c7..1e0d30b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/.qgis-plugin-ci b/.qgis-plugin-ci deleted file mode 100644 index bca683a..0000000 --- a/.qgis-plugin-ci +++ /dev/null @@ -1,5 +0,0 @@ -plugin_path: nlsgpkgloader -github_organization_slug: GispoCoding -project_slug: NLSgpkgloader -transifex_coordinator: replace-me -transifex_organization: replace-me diff --git a/nlsgpkgloader/nls_geopackage_loader.py b/nlsgpkgloader/nls_geopackage_loader.py index fa312fa..46abad1 100644 --- a/nlsgpkgloader/nls_geopackage_loader.py +++ b/nlsgpkgloader/nls_geopackage_loader.py @@ -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 @@ -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(), ) @@ -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): @@ -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 @@ -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": @@ -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 @@ -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) @@ -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 @@ -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() @@ -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 = ( @@ -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 diff --git a/pyproject.toml b/pyproject.toml index a48650c..7270c30 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/requirements-dev.in b/requirements-dev.in new file mode 100644 index 0000000..465a984 --- /dev/null +++ b/requirements-dev.in @@ -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 diff --git a/requirements-dev.txt b/requirements-dev.txt index 5d5f218..a8557a2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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