Skip to content

Commit f0ce0b6

Browse files
committed
chore: downgrading ruff
1 parent f39d8fe commit f0ce0b6

25 files changed

Lines changed: 49 additions & 61 deletions

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install black ruff
41+
pip install black "ruff==0.15.22"
4242
- name: Autoformat with black
4343
run: |
4444
black .

loopstructural/__about__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def plugin_metadata_as_dict() -> dict:
5555
config.read(PLG_METADATA_FILE.resolve(), encoding="UTF-8")
5656
return {s: dict(config.items(s)) for s in config.sections()}
5757
else:
58-
raise IOError("Plugin metadata.txt not found at: %s" % PLG_METADATA_FILE)
58+
raise OSError("Plugin metadata.txt not found at: %s" % PLG_METADATA_FILE)
5959

6060

6161
# ############################################################################
@@ -66,7 +66,7 @@ def plugin_metadata_as_dict() -> dict:
6666
__plugin_md__: dict = plugin_metadata_as_dict()
6767

6868
__author__: str = __plugin_md__.get("general").get("author")
69-
__copyright__: str = "2024 - {0}, {1}".format(date.today().year, __author__)
69+
__copyright__: str = f"2024 - {date.today().year}, {__author__}"
7070
__email__: str = __plugin_md__.get("general").get("email")
7171
__icon_path__: Path = DIR_PLUGIN_ROOT.resolve() / __plugin_md__.get("general").get("icon")
7272
__keywords__: list = [

loopstructural/debug_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ def log_params(self, context_label: str, params: Any):
245245
"""
246246
try:
247247
self.plugin.log(
248-
message=f"[map2loop] {context_label} parameters: {str(params)}",
248+
message=f"[map2loop] {context_label} parameters: {params!s}",
249249
log_level=0,
250250
)
251251
except Exception as err:
252252
self.plugin.log(
253253
message=(
254-
f"[map2loop] {context_label} parameters (stringified due to {err}): {str(params)}"
254+
f"[map2loop] {context_label} parameters (stringified due to {err}): {params!s}"
255255
),
256256
log_level=0,
257257
)

loopstructural/gui/data_conversion/configuration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
from __future__ import annotations
44

5+
from collections.abc import Iterable, MutableMapping
56
from copy import deepcopy
6-
from typing import Any, Dict, Iterable, MutableMapping
7+
from typing import Any, Dict
78

89

910
class Config:

loopstructural/gui/data_conversion/data_conversion_widget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import os
66
import re
7+
from collections.abc import Iterable, Mapping
78
from dataclasses import dataclass
8-
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple
9+
from typing import Any, Dict, List, Optional, Tuple
910

1011
from LoopDataConverter import Datatype, InputData, LoopConverter, SurveyName
1112
from qgis.core import QgsMapLayerProxyModel, QgsProject, QgsVectorLayer

loopstructural/gui/dlg_settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# ########## Globals ###############
3131
# ##################################
3232

33-
FORM_CLASS, _ = uic.loadUiType(Path(__file__).parent / "{}.ui".format(Path(__file__).stem))
33+
FORM_CLASS, _ = uic.loadUiType(Path(__file__).parent / f"{Path(__file__).stem}.ui")
3434

3535

3636
# ############################################################################
@@ -48,7 +48,7 @@ def __init__(self, parent):
4848

4949
# load UI and set objectName
5050
self.setupUi(self)
51-
self.setObjectName("mOptionsPage{}".format(__title__))
51+
self.setObjectName(f"mOptionsPage{__title__}")
5252

5353
_report_context_message = quote(
5454
"> Reported from plugin settings\n\n"

loopstructural/gui/map2loop_tools/basal_contacts_widget.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ def set_parameters(self, params):
277277
params : dict
278278
Dictionary of parameters to set.
279279
"""
280-
if 'geology_layer' in params and params['geology_layer']:
280+
if params.get('geology_layer'):
281281
self.geologyLayerComboBox.setLayer(params['geology_layer'])
282-
if 'faults_layer' in params and params['faults_layer']:
282+
if params.get('faults_layer'):
283283
self.faultsLayerComboBox.setLayer(params['faults_layer'])
284-
if 'ignore_units' in params and params['ignore_units']:
284+
if params.get('ignore_units'):
285285
self.ignoreUnitsLineEdit.setText(', '.join(params['ignore_units']))
286286
if 'all_contacts' in params:
287287
self.allContactsCheckBox.setChecked(params['all_contacts'])
@@ -310,7 +310,7 @@ def _is_null_like(v):
310310
if v is None:
311311
return True
312312
# PyQGIS QVariant null check
313-
if hasattr(v, "isNull") and callable(getattr(v, "isNull")) and v.isNull():
313+
if hasattr(v, "isNull") and callable(v.isNull) and v.isNull():
314314
return True
315315
# Empty strings or literal "NULL" (case-insensitive)
316316
if isinstance(v, str):

loopstructural/gui/map2loop_tools/paint_stratigraphic_order_widget.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def __init__(self, parent=None, data_manager=None, debug_manager=None):
4040
try:
4141
self.geologyLayerComboBox.setFilters(QgsMapLayerProxyModel.PolygonLayer)
4242
# stratigraphic column layer removed from UI
43-
pass
4443
except Exception:
4544
# If QGIS isn't available, skip filter setup
4645
pass
@@ -60,7 +59,6 @@ def __init__(self, parent=None, data_manager=None, debug_manager=None):
6059
if self._debug.is_debug():
6160
raise e
6261
# if QGIS unavailable, leave empty
63-
pass
6462

6563
# Default: no duplication
6664
try:
@@ -132,7 +130,6 @@ def _setup_field_combo_boxes(self):
132130
"""Set up field combo boxes based on current layers."""
133131
self._on_geology_layer_changed()
134132
# stratigraphic column layer removed from UI
135-
pass
136133

137134
def _on_geology_layer_changed(self):
138135
"""Update unit name field combo box when geology layer changes."""

loopstructural/gui/map2loop_tools/sampler_widget.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ def _on_spatial_layer_changed(self):
190190
self.samplerTypeComboBox.setCurrentIndex(idx)
191191
except Exception as e:
192192
print(e)
193-
pass
194193
self.samplerTypeComboBox.setEnabled(False)
195194
self.runButton.setEnabled(True)
196195
elif geom_type == QgsWkbTypes.LineGeometry:
@@ -200,7 +199,6 @@ def _on_spatial_layer_changed(self):
200199
self.samplerTypeComboBox.setCurrentIndex(idx)
201200
except Exception as e:
202201
print(e)
203-
pass
204202
self.samplerTypeComboBox.setEnabled(False)
205203
self.runButton.setEnabled(False)
206204
else:
@@ -372,7 +370,7 @@ def _run_sampler(self):
372370
)
373371
if PlgOptionsManager.get_debug_mode():
374372
raise e
375-
QMessageBox.critical(self, "Error", f"An error occurred: {str(e)}")
373+
QMessageBox.critical(self, "Error", f"An error occurred: {e!s}")
376374
return False
377375

378376
def get_parameters(self):
@@ -402,11 +400,11 @@ def set_parameters(self, params):
402400
"""
403401
if 'sampler_type' in params:
404402
self.samplerTypeComboBox.setCurrentIndex(params['sampler_type'])
405-
if 'dtm_layer' in params and params['dtm_layer']:
403+
if params.get('dtm_layer'):
406404
self.dtmLayerComboBox.setLayer(params['dtm_layer'])
407-
if 'geology_layer' in params and params['geology_layer']:
405+
if params.get('geology_layer'):
408406
self.geologyLayerComboBox.setLayer(params['geology_layer'])
409-
if 'spatial_data_layer' in params and params['spatial_data_layer']:
407+
if params.get('spatial_data_layer'):
410408
self.spatialDataLayerComboBox.setLayer(params['spatial_data_layer'])
411409
if 'decimation' in params:
412410
self.decimationSpinBox.setValue(params['decimation'])

loopstructural/gui/map2loop_tools/sorter_widget.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def _run_sorter(self):
442442
)
443443
if PlgOptionsManager.get_debug_mode():
444444
raise e
445-
QMessageBox.critical(self, "Error", f"An error occurred: {str(e)}")
445+
QMessageBox.critical(self, "Error", f"An error occurred: {e!s}")
446446
return False
447447

448448
def get_parameters(self):
@@ -484,7 +484,7 @@ def set_parameters(self, params):
484484
"""
485485
if 'sorting_algorithm' in params:
486486
self.sortingAlgorithmComboBox.setCurrentIndex(params['sorting_algorithm'])
487-
if 'geology_layer' in params and params['geology_layer']:
487+
if params.get('geology_layer'):
488488
self.geologyLayerComboBox.setLayer(params['geology_layer'])
489-
if 'contacts_layer' in params and params['contacts_layer']:
489+
if params.get('contacts_layer'):
490490
self.contactsLayerComboBox.setLayer(params['contacts_layer'])

0 commit comments

Comments
 (0)