Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 22, 2024
1 parent 38e92b9 commit dd01287
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 35 deletions.
10 changes: 2 additions & 8 deletions LDMP/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"""

import io
import sys
import typing

from future import standard_library

Expand All @@ -25,9 +23,7 @@
import requests
import backoff

from dateutil import tz
from qgis.core import (
QgsApplication,
QgsTask,
QgsNetworkAccessManager,
QgsApplication,
Expand All @@ -36,8 +32,6 @@
)
from qgis.PyQt import QtCore, QtWidgets, QtNetwork

from qgis.utils import iface
from qgis.gui import QgsAuthConfigSelect

from . import auth, conf
from .logger import log
Expand Down Expand Up @@ -106,7 +100,7 @@ def run(self):
# dictionaries that contain nested values of OrderedDict.
try:
doc = QtCore.QJsonDocument(self.payload)
except TypeError as te:
except TypeError:
request_data = bytes(json.dumps(self.payload), encoding="utf-8")

request_data = (
Expand Down Expand Up @@ -191,7 +185,7 @@ def finished(self, result):
)
except requests.exceptions.Timeout:
self.error_message = tr_api.tr(
f"Unable to connect to Trends.Earth server."
"Unable to connect to Trends.Earth server."
)

if self.resp is not None:
Expand Down
1 change: 0 additions & 1 deletion LDMP/areaofinterest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import json
import traceback
import typing
from pathlib import Path

Expand Down
2 changes: 0 additions & 2 deletions LDMP/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import typing
import uuid
from pathlib import Path
from typing import Optional

import qgis.core
import qgis.gui
Expand All @@ -39,7 +38,6 @@
from .conf import REMOTE_DATASETS
from .conf import Setting
from .conf import settings_manager
from .logger import log


DlgCalculateUi, _ = uic.loadUiType(str(Path(__file__).parent / "gui/DlgCalculate.ui"))
Expand Down
6 changes: 1 addition & 5 deletions LDMP/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
from functools import partial
from pathlib import Path

import requests
from qgis.core import QgsApplication
from qgis.core import QgsFileDownloader
from qgis.core import QgsNetworkReplyContent
from qgis.core import QgsSettings
from qgis.core import QgsTask
from qgis.PyQt import QtCore
from qgis.PyQt import QtNetwork
from qgis.PyQt import QtWidgets
Expand Down Expand Up @@ -392,7 +388,7 @@ def start(self):
tr_download.tr("Error"),
tr_download.tr("Download failed. Check your internet connection."),
)
except Exception as err:
except Exception:
QtWidgets.QMessageBox.critical(
None,
tr_download.tr("Error"),
Expand Down
2 changes: 1 addition & 1 deletion LDMP/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(
max_x = item.get("Max Longitude", None)
min_y = item.get("Min Latitude", None)
max_y = item.get("Max Latitude", None)
if not None in (min_x, max_x, min_y, max_y):
if None not in (min_x, max_x, min_y, max_y):
extent_lat = "{} - {}".format(min_y, max_y)
extent_lon = "{} - {}".format(min_x, max_x)
item.update({"extent_lat": extent_lat, "extent_lon": extent_lon})
Expand Down
5 changes: 2 additions & 3 deletions LDMP/jobs/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import datetime as dt
import json
import logging
Expand Down Expand Up @@ -799,7 +798,7 @@ def create_error_recode(self, task_name, lc, soil, prod, sdg):
status=jobs.JobStatus.DOWNLOADED,
local_context=_get_local_context(),
results=VectorResults(
name=f"False positive/negative",
name="False positive/negative",
type=ResultType.VECTOR_RESULTS,
vector=VectorFalsePositive(
uri=None,
Expand Down Expand Up @@ -1166,7 +1165,7 @@ def _get_local_jobs(self, status: jobs.JobStatus) -> typing.List[Job]:
raw_job = json.load(fh)
job = Job.Schema().load(raw_job)
set_results_extents(job)
except (KeyError, json.decoder.JSONDecodeError) as exc:
except (KeyError, json.decoder.JSONDecodeError):
if conf.settings_manager.get_value(conf.Setting.DEBUG):
log(
f"Unable to decode file {job_metadata_path!r} as valid json"
Expand Down
1 change: 0 additions & 1 deletion LDMP/jobs/mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from ..conf import settings_manager
from ..data_io import DlgDataIOAddLayersToMap
from ..datasets_dialog import DatasetDetailsDialogue
from ..logger import log
from ..plot import DlgPlotTimeries
from ..reports.mvc import DatasetReportHandler
from ..select_dataset import DlgSelectDataset
Expand Down
4 changes: 2 additions & 2 deletions LDMP/landpks.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(
max_x = item.get("Max Longitude", None)
min_y = item.get("Min Latitude", None)
max_y = item.get("Max Latitude", None)
if not None in (min_x, max_x, min_y, max_y):
if None not in (min_x, max_x, min_y, max_y):
extent_lat = "{} - {}".format(min_y, max_y)
extent_lon = "{} - {}".format(min_x, max_x)
item.update({"extent_lat": extent_lat, "extent_lon": extent_lon})
Expand Down Expand Up @@ -241,7 +241,7 @@ def btn_calculate(self):
log(f"ret: {ret}")
if not ret:
return
log(f"continuing...")
log("continuing...")

rows = list({index.row() for index in self.data_view.selectedIndexes()})
# Construct unique dataset names as the concatenation of the category
Expand Down
5 changes: 3 additions & 2 deletions LDMP/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ def add_layer(
)
log(
'No style found for "{}" in {}'.format(
band_info["name"], band_number, layer_path
band_info["name"],
band_number,
)
)

Expand Down Expand Up @@ -836,7 +837,7 @@ def add_vector_layer(layer_path: str, name: str) -> "QgsVectorLayer":


def set_default_stats_value(v_path, band_datas):
log(f"setting default stats value function")
log("setting default stats value function")
layer = None
for l in QgsProject.instance().mapLayers().values():
if l.source().split("|")[0] == v_path:
Expand Down
2 changes: 1 addition & 1 deletion LDMP/lc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def _get_default_matrix():
os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"data",
f"land_cover_transition_matrix_unccd.json",
"land_cover_transition_matrix_unccd.json",
)
)

Expand Down
1 change: 0 additions & 1 deletion LDMP/maptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from qgis.core import QgsRectangle
from qgis.core import QgsUnitTypes
from qgis.core import QgsVectorLayerUtils
from qgis.core import QgsWkbTypes
from qgis.gui import QgsDoubleSpinBox
from qgis.gui import QgsMapCanvas
from qgis.gui import QgsMapMouseEvent
Expand Down
1 change: 0 additions & 1 deletion LDMP/region_selector.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dataclasses import dataclass

from qgis.core import QgsGeometry
from qgis.core import QgsRectangle
from qgis.PyQt import QtCore
from qgis.PyQt import QtWidgets
from qgis.utils import iface
Expand Down
2 changes: 1 addition & 1 deletion LDMP/reports/mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def update_report_status(self) -> bool:
def check_job_report_status(self) -> bool:
# Check job status, assert datasets are available and no report has
# been generated yet.
if not self._job.status in (JobStatus.DOWNLOADED, JobStatus.GENERATED_LOCALLY):
if self._job.status not in (JobStatus.DOWNLOADED, JobStatus.GENERATED_LOCALLY):
return False

if not job_has_results(self._job):
Expand Down
9 changes: 5 additions & 4 deletions LDMP/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
email : [email protected]
***************************************************************************/
"""

import os
import typing
import zipfile
Expand All @@ -29,7 +30,6 @@
from qgis.utils import iface
from te_schemas.land_cover import LCClass

from . import __version__
from . import api
from . import auth
from . import binaries_available
Expand Down Expand Up @@ -1325,8 +1325,9 @@ def binaries_download(self):
None,
self.tr("Error"),
self.tr(
"Unable to write to {}. Try a "
"different folder.".format(out_folder)
"Unable to write to {}. Try a " "different folder.".format(
out_folder
)
),
)

Expand Down Expand Up @@ -1385,7 +1386,7 @@ def binaries_download(self):
QtWidgets.QMessageBox.critical(
None,
self.tr("Success"),
self.tr("All binaries up to date.".format(out_folder)),
self.tr("All binaries up to date.".format()),
)

def binaries_toggle(self):
Expand Down
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def set_tag(c, modules=False):
)
ret.check_returncode()
else:
print("Changes not committed - VERSION TAG NOT SET".format(v))
print("Changes not committed - VERSION TAG NOT SET".format())

print("Tagging version {} and pushing tag to origin".format(v))
ret = subprocess.run(
Expand Down Expand Up @@ -1663,7 +1663,7 @@ def _s3_sync(c, bucket, s3_prefix, local_folder, patterns=["*"]):
if os.path.isdir(f):
continue

if not os.path.basename(f) in s3_object_names:
if os.path.basename(f) not in s3_object_names:
print("S3 is missing {} - copying to S3.".format(f))
data = open(f, "rb")
client.put_object(
Expand Down

0 comments on commit dd01287

Please sign in to comment.