From 102bc38d16df035dbb0b4caf0f16e7fda0d12273 Mon Sep 17 00:00:00 2001 From: Makiko Shukunobe Date: Fri, 6 Sep 2024 21:47:24 -0400 Subject: [PATCH] checks: Flake8 F841 fixes in the scripts directory part 2 (#4241) * Fix F841 problems in `scripts` directory * Update `.flake8` with fixes for F841 * Remove unused lines based on reviewed suggestions --- .flake8 | 8 ++++---- scripts/r.semantic.label/r.semantic.label.py | 4 ++-- scripts/v.import/v.import.py | 2 -- scripts/v.report/v.report.py | 3 --- scripts/v.unpack/v.unpack.py | 4 ---- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.flake8 b/.flake8 index 18cea9165ce..47fa3239a24 100644 --- a/.flake8 +++ b/.flake8 @@ -158,12 +158,12 @@ per-file-ignores = scripts/r.in.wms/wms_cap_parsers.py: F841 scripts/r.in.wms/wms_drv.py: E402, E722 scripts/r.in.wms/srs.py: E722 - scripts/r.semantic.label/r.semantic.label.py: F841, E501 - scripts/v.report/v.report.py: F841, E721 + scripts/r.semantic.label/r.semantic.label.py: E501 + scripts/v.report/v.report.py: E721 scripts/db.out.ogr/db.out.ogr.py: F841 scripts/g.extension/g.extension.py: F841, E722, E501 - scripts/v.unpack/v.unpack.py: F841, E722, E501 - scripts/v.import/v.import.py: F841, E722, E501 + scripts/v.unpack/v.unpack.py: E722, E501 + scripts/v.import/v.import.py: E722, E501 scripts/db.univar/db.univar.py: E501 scripts/d.frame/d.frame.py: E722 scripts/i.pansharpen/i.pansharpen.py: E722, E501 diff --git a/scripts/r.semantic.label/r.semantic.label.py b/scripts/r.semantic.label/r.semantic.label.py index 53239772117..f3c26320ae3 100644 --- a/scripts/r.semantic.label/r.semantic.label.py +++ b/scripts/r.semantic.label/r.semantic.label.py @@ -62,7 +62,7 @@ def print_map_semantic_label(name, label_reader): label_reader.print_info(semantic_label=semantic_label) else: gs.info(_("No semantic label assigned to <{}>").format(name)) - except OpenError as e: + except OpenError: gs.error(_("Map <{}> not found").format(name)) @@ -94,7 +94,7 @@ def manage_map_semantic_label(name, semantic_label): except GrassError as e: gs.error(_("Unable to assign/dissociate semantic label. {}").format(e)) return 1 - except OpenError as e: + except OpenError: gs.error(_("Map <{}> not found in current mapset").format(name)) return 1 diff --git a/scripts/v.import/v.import.py b/scripts/v.import/v.import.py index 42e5952c76f..4f579c4bf45 100755 --- a/scripts/v.import/v.import.py +++ b/scripts/v.import/v.import.py @@ -257,8 +257,6 @@ def main(): f.write("GUI: text\n") f.close() - tgtsrs = gs.read_command("g.proj", flags="j", quiet=True) - # create temp location from input without import gs.verbose(_("Creating temporary project for <%s>...") % OGRdatasource) try: diff --git a/scripts/v.report/v.report.py b/scripts/v.report/v.report.py index 8da23bbaf91..18752a697cb 100755 --- a/scripts/v.report/v.report.py +++ b/scripts/v.report/v.report.py @@ -216,9 +216,6 @@ def main(): if not flags["c"]: sys.stdout.write(fs.join(colnames + extracolnames) + "\n") - # make and print the table: - numcols = len(colnames) + len(extracolnames) - # calculate percents if requested if units == "percent" and option != "coor": # calculate total value diff --git a/scripts/v.unpack/v.unpack.py b/scripts/v.unpack/v.unpack.py index af430f98829..0507e9eb400 100644 --- a/scripts/v.unpack/v.unpack.py +++ b/scripts/v.unpack/v.unpack.py @@ -215,10 +215,6 @@ def main(): # the db connection in the output mapset dbconn = grassdb.db_connection(force=True) todb = dbconn["database"] - # return all tables - list_fromtable = grass.read_command( - "db.tables", driver="sqlite", database=fromdb - ).splitlines() # return the list of old connection for extract layer number and key dbln = open(os.path.join(new_dir, "dbln"), "r")