Skip to content

Commit

Permalink
Merge pull request #112 from QGEP/poa_precommit_ci
Browse files Browse the repository at this point in the history
Upgrade precommit librairies and add to CI
  • Loading branch information
ponceta authored Sep 26, 2024
2 parents 7b4424c + f9aecf5 commit e3d1540
Show file tree
Hide file tree
Showing 31 changed files with 271 additions and 615 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/pre-commit.yaml

This file was deleted.

40 changes: 36 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exclude: '^.*\.xtf|.*\.xml|.*\.ili|qgepqwat2ili/bin.*$'
repos:
# Fix end of files
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -14,7 +14,7 @@ repos:

# Remove unused imports/variables
- repo: https://github.com/myint/autoflake
rev: v2.0.1
rev: v2.3.1
hooks:
- id: autoflake
args:
Expand All @@ -24,7 +24,7 @@ repos:

# Sort imports
- repo: https://github.com/pycqa/isort
rev: "5.12.0"
rev: "5.13.2"
hooks:
- id: isort
args:
Expand All @@ -33,6 +33,38 @@ repos:

# Black formatting
- repo: https://github.com/psf/black
rev: 22.12.0
rev: "24.4.2"
hooks:
- id: black
args: ["--line-length=99"]

# tool to automatically upgrade syntax for newer versions of the language
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
- id: pyupgrade
args: [--py37-plus]

# Lint files
- repo: https://github.com/pycqa/flake8
rev: "7.1.0"
hooks:
- id: flake8
args: [
"--max-line-length=115",
# ignore long comments (E501), as long lines are formatted by black
"--ignore=E501,E203,W503",
]

# # Static type-checking with mypy
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: 'v1.5.1'
# hooks:
# - id: mypy
# additional_dependencies: [types-pytz, types-Deprecated, types-PyYAML, types-requests, types-tabulate, types-jsonschema, django-stubs]
# pass_filenames: false
# entry: bash -c 'mypy -p docker-qgis -p docker-app "$@"' --

ci:
autofix_prs: true
autoupdate_schedule: quarterly
1 change: 0 additions & 1 deletion qgepplugin/gui/dlgabout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------
#
# Profile
Expand Down
36 changes: 25 additions & 11 deletions qgepplugin/gui/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ def mapToolDeactivated(tool):
def digitizeDrainageChannel(fid, layerid):
layer = QgsProject.instance().mapLayer(layerid)
layer.startEditing()
tool = QgepMapToolDigitizeDrainageChannel(
qgis.utils.plugins["qgepplugin"].iface, layer
)
tool = QgepMapToolDigitizeDrainageChannel(qgis.utils.plugins["qgepplugin"].iface, layer)
qgis.utils.plugins["qgepplugin"].iface.mapCanvas().setMapTool(tool)
tool.geometryDigitized.connect(lambda: geometryDigitized(fid, layer, tool))

def on_geometry_digitized():
geometryDigitized(fid, layer, tool)

def on_tool_deactivated():
mapToolDeactivated(tool)

tool.geometryDigitized.connect(on_geometry_digitized)
# form.window().hide()
tool.deactivated.connect(lambda: mapToolDeactivated(tool))
tool.deactivated.connect(on_tool_deactivated)


def manholeOpen(form, layer, feature):
Expand All @@ -37,17 +42,26 @@ def manholeOpen(form, layer, feature):
except TypeError:
pass

def digitize():
digitizeDrainageChannel(form, feature, layer)

def enable_button():
button.setEnabled(True)

def disable_button():
button.setEnabled(False)

if feature.isValid():
button.clicked.connect(lambda: digitizeDrainageChannel(form, feature, layer))
button.clicked.connect(digitize)
button.setEnabled(layer.isEditable())

enable_button = lambda: button.setEnabled(True)
disable_button = lambda: button.setEnabled(False)

layer.editingStarted.connect(enable_button)
layer.editingStopped.connect(disable_button)

form.destroyed.connect(lambda: layer.editingStarted.disconnect(enable_button))
form.destroyed.connect(lambda: layer.editingStopped.disconnect(disable_button))
def cleanup():
layer.editingStarted.disconnect(enable_button)
layer.editingStopped.disconnect(disable_button)

form.destroyed.connect(cleanup)
else:
button.setEnabled(False)
Loading

0 comments on commit e3d1540

Please sign in to comment.