Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #850

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: check-yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.9.4
hooks:
- id: ruff
args: ["check", "--select", "I", "--fix"]
Expand Down
9 changes: 3 additions & 6 deletions LDMP/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,15 @@ def login(self, authConfigId=None):
except KeyError:
log("API unable to login - check username and password")
error_message = tr_api.tr(
"Unable to login to Trends.Earth. " "Check username and password."
"Unable to login to Trends.Earth. Check username and password."
)
ret = None
else:
ret = token
else:
log("Unable to access Trends.Earth server")
error_message = tr_api.tr(
"Unable to access Trends.Earth server. Check your "
"internet connection"
"Unable to access Trends.Earth server. Check your internet connection"
)
ret = None

Expand All @@ -291,9 +290,7 @@ def login_test(self, email, password):
return True
else:
if not email or not password:
log(
"API unable to login during login test - check " "username/password"
)
log("API unable to login during login test - check username/password")
QtWidgets.QMessageBox.critical(
None,
tr_api.tr("Error"),
Expand Down
4 changes: 2 additions & 2 deletions LDMP/areaofinterest.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ def meridian_split(self, out_type="extent", out_format="geojson", warn=True):
# original layer (or extent) if the area of the combined pieces
# from both hemispheres is not significantly smaller than that of
# the original polygon.
log("AOI being processed in one piece " "(does not cross 180th meridian)")
log("AOI being processed in one piece (does not cross 180th meridian)")
return (False, [pieces_union_txt])
else:
log("AOI crosses 180th meridian - " "splitting AOI into two geojsons.")
log("AOI crosses 180th meridian - splitting AOI into two geojsons.")
return (True, pieces_txt)

def get_aligned_output_bounds(self, f):
Expand Down
4 changes: 1 addition & 3 deletions LDMP/calculate_drought_vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ def validate_layer_extents(self, combo_boxes):
QtWidgets.QMessageBox.critical(
None,
self.tr("Error"),
self.tr(
"Area of interest is not entirely within the " "drought dataset."
),
self.tr("Area of interest is not entirely within the drought dataset."),
)

return False
Expand Down
4 changes: 2 additions & 2 deletions LDMP/calculate_ldn.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def btn_calculate(self):
}
)

log(f'period is: {payload["period"]}')
log(f"period is: {payload['period']}")

payloads.append(payload)

Expand Down Expand Up @@ -1149,7 +1149,7 @@ def set_layer_filter(self):
"layer_type", ld_config.SOC_DEG_BAND_NAME
)
self.combo_layer_input.populate()
log(f'filter set to {self.combo_layer_input.property("layer_type")}')
log(f"filter set to {self.combo_layer_input.property('layer_type')}")

def btn_calculate(self):
# Note that the super class has several tests in it - if they fail it
Expand Down
9 changes: 4 additions & 5 deletions LDMP/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ def _load_algorithm_config(
"id": "277f87e6-5362-4533-ab1d-c28251576884",
"name": tr_conf.tr("Land cover change"),
"description": tr_conf.tr(
"Land cover is the physical material at the surface of "
"the earth. "
"Land cover is the physical material at the surface of the earth. "
),
"scripts": [
{
Expand All @@ -325,7 +324,7 @@ def _load_algorithm_config(
"name": tr_conf.tr("Soil Organic Carbon"),
"description": (
tr_conf.tr(
"Soil organic carbon is a measure of soil organic " "matter"
"Soil organic carbon is a measure of soil organic matter"
)
),
"scripts": [
Expand Down Expand Up @@ -475,7 +474,7 @@ def _load_algorithm_config(
"id": "a753f2c9-be4c-4d97-9e21-09b8882e8899",
"name": tr_conf.tr("Change in carbon summary table"),
"description": tr_conf.tr(
"Calculate table summarizing change in " "total carbon"
"Calculate table summarizing change in total carbon"
),
"scripts": [
{
Expand All @@ -494,7 +493,7 @@ def _load_algorithm_config(
"id": "61839d52-0d81-428d-90e6-83ea5ed3c032",
"name": tr_conf.tr("Estimate potential impacts of restoration"),
"description": tr_conf.tr(
"Estimate potential change in biomass due to " "restoration"
"Estimate potential change in biomass due to restoration"
),
"scripts": [
{
Expand Down
2 changes: 1 addition & 1 deletion LDMP/data_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ def validate_overlap(self, user_warning=True) -> bool:
if user_warning:
reg_name = self.region_selector.region_info.area_name
self.msg_bar.pushMessage(
self.tr(f"Output file will be resized " f"to '{reg_name}' extent."),
self.tr(f"Output file will be resized to '{reg_name}' extent."),
qgis.core.Qgis.MessageLevel.Warning,
8,
)
Expand Down
6 changes: 1 addition & 5 deletions LDMP/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,7 @@ def update_progress(self, value, total):
self.progress.emit(value * 100 / total)

def download_error(self, error):
log(
tr_download.tr(
f"Error while downloading file to" f" {self.outfile}, {error}"
)
)
log(tr_download.tr(f"Error while downloading file to {self.outfile}, {error}"))
raise DownloadError(
"Unable to start download of {}, {}".format(self.url, error)
)
Expand Down
2 changes: 1 addition & 1 deletion LDMP/jobs/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ def _delete_job_datasets(job: Job):
path = os.path.split(job_manager.get_job_file_path(job))[0]
shutil.rmtree(path)
except OSError:
log(f"Could not remove directory {path!r}, " "skipping deletion...")
log(f"Could not remove directory {path!r}, skipping deletion...")
else:
log("This job has no results to be deleted, skipping...")

Expand Down
4 changes: 2 additions & 2 deletions LDMP/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ def get_sample(f, band_number, n=1e6):
)
log(
"Resampling to "
f'/vsimem/resample_{Path(f).with_suffix(".tif").name}, from {f}'
f"/vsimem/resample_{Path(f).with_suffix('.tif').name}, from {f}"
)
ds_resamp = gdal.Translate(
f'/vsimem/{Path(f).with_suffix(".tif").name}',
f"/vsimem/{Path(f).with_suffix('.tif').name}",
f,
bandList=[band_number],
width=xsize_new,
Expand Down
8 changes: 3 additions & 5 deletions LDMP/lc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def read_lc_nesting_file(f):
with open(f) as nesting_file:
nesting = LCLegendNesting.Schema().loads(nesting_file.read())
except ValidationError as e:
log("Error loading land cover legend " f"nesting definition from {f}: {e}")
log(f"Error loading land cover legend nesting definition from {f}: {e}")
QtWidgets.QMessageBox.critical(
None,
tr_lc_setup.tr("Error"),
Expand Down Expand Up @@ -1768,8 +1768,7 @@ def sync_trans_matrix(ref_lcc_infos: list[LCClassInfo]):
trans_matrix_to_settings(matrix)
if conf.settings_manager.get_value(conf.Setting.DEBUG):
log(
f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved updated matrix to "
f"settings."
f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved updated matrix to settings."
)

@staticmethod
Expand Down Expand Up @@ -1928,8 +1927,7 @@ def save_lc_nesting_esa(ref_lcc_infos: list[LCClassInfo]):
log(f"child codes are {current_nesting.child.codes()}")

log(
f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved ESA lc "
f"nesting to settings."
f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved ESA lc nesting to settings."
)

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions LDMP/localexecution/biomassrestoration.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def compute_biomass_restoration(
)
clip_worker = worker.StartWorker(
calculate.ClipWorker,
f"masking layers (part {n+1} of {len(wkts)})",
f"masking layers (part {n + 1} of {len(wkts)})",
in_file,
str(output_biomass_diff_tif),
geojson,
Expand All @@ -88,7 +88,7 @@ def compute_biomass_restoration(
logger.log("Calculating summary table...")
rest_summary_worker = worker.StartWorker(
RestBiomassSummaryWorker,
f"calculating summary table (part {n+1} of {len(wkts)})",
f"calculating summary table (part {n + 1} of {len(wkts)})",
str(output_biomass_diff_tif),
)

Expand Down
8 changes: 4 additions & 4 deletions LDMP/localexecution/unccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ def _set_error_recode(in_file, out_file, error_recode_polys):
sdg_areas[recode_from] -= area
sdg_areas["Improved"] += area

assert all(
value >= 0 for value in sdg_areas.values()
), f"sdg_areas should all be greater than zero, but values are {sdg_areas}"
assert all(value >= 0 for value in sdg_areas.values()), (
f"sdg_areas should all be greater than zero, but values are {sdg_areas}"
)
total_area_final = sum(sdg_areas.values())
assert abs(total_area_initial - total_area_final) < 0.001, (
f"total_area_initial ({total_area_initial}) differs "
Expand Down Expand Up @@ -222,7 +222,7 @@ def compute_unccd_report(
for i in range(len(params["so1_so2_all_paths"])):
if params["so1_so2_all_paths"][i] == str(orig_summary_path_so1_so2):
log(
f'Replacing {str(params["so1_so2_all_paths"][i])} with '
f"Replacing {str(params['so1_so2_all_paths'][i])} with "
f"{str(new_summary_path_so1_so2)}"
)
params["so1_so2_all_paths"][i] = str(new_summary_path_so1_so2)
Expand Down
2 changes: 1 addition & 1 deletion LDMP/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def setup_algorithms_tree(self):

def create_error_recode(self):
dlg = DlgSelectDataset(self, validate_all=True)
win_title = f'{dlg.windowTitle()} - {self.tr("False positive/negative")}'
win_title = f"{dlg.windowTitle()} - {self.tr('False positive/negative')}"
dlg.setWindowTitle(win_title)
if dlg.exec_() == QtWidgets.QDialog.Accepted:
self.pause_scheduler()
Expand Down
4 changes: 2 additions & 2 deletions LDMP/reports/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def export(self) -> typing.Tuple[bool, list]:
if not file_name_base:
file_name_base = self.layer_name()

output_file_path = f"{self.root_output_dir}/" f"chart-{file_name_base}.png"
output_file_path = f"{self.root_output_dir}/chart-{file_name_base}.png"

labels = []
values = []
Expand Down Expand Up @@ -903,7 +903,7 @@ def _add_charts(self):
productivity_barchart.data_items = lc_prod_info_items
productivity_barchart.use_value_type = InfoValueType.PERCENT
productivity_barchart.base_chart_name = (
f"land-cover-change-by-" f"productivity-{init_year!s}" f"-{final_year!s}"
f"land-cover-change-by-productivity-{init_year!s}-{final_year!s}"
)
productivity_barchart.value_axis_label = tr_reports_charts.tr("%")
self._charts.append(productivity_barchart)
Expand Down
9 changes: 4 additions & 5 deletions LDMP/reports/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def _restore_base_layers(self):
basemap_group = root_tree.findGroup(self.BASE_MAP_GROUP)
if basemap_group is None:
self._append_warning_msg(
"Basemap root group not found, unable to restore basemap " "layer."
"Basemap root group not found, unable to restore basemap layer."
)
return

Expand Down Expand Up @@ -1013,8 +1013,7 @@ def process_report_task(self, ctx: ReportTaskContext) -> bool:
# Assert if qgis_process path could be found
if not self._qgis_proc_path:
tr_msg = self.tr(
"could not be found in your system. Unable to run the "
"report generator."
"could not be found in your system. Unable to run the report generator."
)
self._push_warning_message(f"'qgis_process' {tr_msg}")
return False
Expand Down Expand Up @@ -1042,7 +1041,7 @@ def process_report_task(self, ctx: ReportTaskContext) -> bool:

# Notify user
tr_msg = self.tr(
f"are being processed (id " f"{[str(job.id) for job in ctx.jobs]})..."
f"are being processed (id {[str(job.id) for job in ctx.jobs]})..."
)
self._push_info_message(f"{ctx_display_name} {tr_msg}")

Expand Down Expand Up @@ -1136,7 +1135,7 @@ def on_task_status_changed(self, task_id: int, status: QgsTask.TaskStatus):
ctx_file = QFile(ctx_file_path)
status = ctx_file.remove()
if not status:
log(f"Unable to remove report context " f"file: {ctx_file_path}")
log(f"Unable to remove report context file: {ctx_file_path}")

# Remove from list of submitted tasks
self.remove_task_context(ctx)
Expand Down
5 changes: 2 additions & 3 deletions LDMP/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ def _get_user_email(auth_setup, warn=True):
None,
tr_settings.tr("Error"),
tr_settings.tr(
"Please setup access to {auth_setup.name} before "
"using this function."
"Please setup access to {auth_setup.name} before using this function."
),
)
return None
Expand Down Expand Up @@ -1790,7 +1789,7 @@ def on_save_file(self):
lcc_infos = self.class_infos()
status = LccInfoUtils.save_file(lcc_save_path, lcc_infos)
if not status:
log(f"Unable to save land cover " f"classes to '{lcc_save_path}'")
log(f"Unable to save land cover classes to '{lcc_save_path}'")
return

fi = QtCore.QFileInfo(lcc_save_path)
Expand Down
3 changes: 1 addition & 2 deletions LDMP/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ def get_plot_title(self):
)
else:
return (
f"{self.traj_indic.currentText()} "
f"- {self.dataset_ndvi.currentText()}"
f"{self.traj_indic.currentText()} - {self.dataset_ndvi.currentText()}"
)

def btn_calculate(self):
Expand Down
2 changes: 1 addition & 1 deletion LDMP/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def qgis_process_path() -> str:

# Check execution permissions
if not os.access(proc_script_path, os.X_OK):
log(f"User does not have execute permission " f"for '{proc_script_path}'.")
log(f"User does not have execute permission for '{proc_script_path}'.")
return ""

return proc_script_path
Expand Down
6 changes: 3 additions & 3 deletions LDMP/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,23 +246,23 @@ def country_data_path() -> str:
"""
Returns the path for the vector file containing country data.
"""
return f"{FileUtils.plugin_dir()}/data/" f"ne_10m_admin_0_countries.shp"
return f"{FileUtils.plugin_dir()}/data/ne_10m_admin_0_countries.shp"


def sub_national_data_path() -> str:
"""
Returns the path for the vector file containing sub-national data.
"""
root_dir = FileUtils.plugin_dir()
return f"{root_dir}/data/" f"ne_10m_admin_1_states_provinces.shp"
return f"{root_dir}/data/ne_10m_admin_1_states_provinces.shp"


def places_data_path() -> str:
"""
Returns the path for the vector file containing data on populated places.
"""
root_dir = FileUtils.plugin_dir()
return f"{root_dir}/data/" f"ne_10m_populated_places.shp"
return f"{root_dir}/data/ne_10m_populated_places.shp"


class ExtractAdministrativeArea:
Expand Down
2 changes: 1 addition & 1 deletion test/test_qgis_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

__author__ = "[email protected]"
__date__ = "20/01/2011"
__copyright__ = "Copyright 2012, Australia Indonesia Facility for " "Disaster Reduction"
__copyright__ = "Copyright 2012, Australia Indonesia Facility for Disaster Reduction"

import os
import unittest
Expand Down
Loading