From 09283a24f0e0e5594dab0952e1ac56b011828899 Mon Sep 17 00:00:00 2001 From: mshukun Date: Wed, 28 Aug 2024 11:37:42 -0400 Subject: [PATCH 1/3] Fix F841 problems in `scripts` directory --- 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 +--- 4 files changed, 4 insertions(+), 9 deletions(-) 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..49301af0ccd 100755 --- a/scripts/v.import/v.import.py +++ b/scripts/v.import/v.import.py @@ -257,7 +257,7 @@ def main(): f.write("GUI: text\n") f.close() - tgtsrs = gs.read_command("g.proj", flags="j", quiet=True) + gs.read_command("g.proj", flags="j", quiet=True) # create temp location from input without import gs.verbose(_("Creating temporary project for <%s>...") % OGRdatasource) 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..853297755c6 100644 --- a/scripts/v.unpack/v.unpack.py +++ b/scripts/v.unpack/v.unpack.py @@ -216,9 +216,7 @@ def main(): dbconn = grassdb.db_connection(force=True) todb = dbconn["database"] # return all tables - list_fromtable = grass.read_command( - "db.tables", driver="sqlite", database=fromdb - ).splitlines() + 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") From 37cf5beabab969650289dc7c60fcb3753cd2d766 Mon Sep 17 00:00:00 2001 From: mshukun Date: Wed, 28 Aug 2024 11:44:00 -0400 Subject: [PATCH 2/3] Update `.flake8` with fixes for F841 --- .flake8 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.flake8 b/.flake8 index 573debabe1c..a9e271c5b30 100644 --- a/.flake8 +++ b/.flake8 @@ -159,12 +159,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 From da6e88b38aaae75f33cc5fbda8d6c25774c3d6cb Mon Sep 17 00:00:00 2001 From: mshukun Date: Wed, 28 Aug 2024 15:15:28 -0400 Subject: [PATCH 3/3] Remove unused lines based on reviewed suggestions --- scripts/v.import/v.import.py | 2 -- scripts/v.unpack/v.unpack.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/scripts/v.import/v.import.py b/scripts/v.import/v.import.py index 49301af0ccd..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() - 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.unpack/v.unpack.py b/scripts/v.unpack/v.unpack.py index 853297755c6..0507e9eb400 100644 --- a/scripts/v.unpack/v.unpack.py +++ b/scripts/v.unpack/v.unpack.py @@ -215,8 +215,6 @@ def main(): # the db connection in the output mapset dbconn = grassdb.db_connection(force=True) todb = dbconn["database"] - # return all tables - 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")