From e53acdc78522001f4fa5ce859cd6451012fda995 Mon Sep 17 00:00:00 2001 From: mshukun Date: Thu, 29 Aug 2024 13:12:10 -0400 Subject: [PATCH 1/3] Delete unused variables and lines to fix F841 --- gui/wxpython/dbmgr/base.py | 9 ++++----- gui/wxpython/dbmgr/dialogs.py | 1 - gui/wxpython/dbmgr/sqlbuilder.py | 5 +---- gui/wxpython/dbmgr/vinfo.py | 3 --- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/gui/wxpython/dbmgr/base.py b/gui/wxpython/dbmgr/base.py index 1c4349bdd8c..7fe62942fb3 100644 --- a/gui/wxpython/dbmgr/base.py +++ b/gui/wxpython/dbmgr/base.py @@ -228,7 +228,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None): if sql: cmdParams.update({"sql": sql, "output": outFile.name, "overwrite": True}) - ret = RunCommand("db.select", **cmdParams) + RunCommand("db.select", **cmdParams) self.sqlFilter = {"sql": sql} else: cmdParams.update( @@ -246,7 +246,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None): # Enclose column name with SQL standard double quotes cmdParams.update({"columns": ",".join([f'"{col}"' for col in columns])}) - ret = RunCommand("v.db.select", **cmdParams) + RunCommand("v.db.select", **cmdParams) # These two should probably be passed to init more cleanly # setting the numbers of items = number of elements in the dictionary @@ -296,7 +296,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None): record = ( decode(outFile.readline(), encoding=enc).strip().replace("\n", "") ) - except UnicodeDecodeError as e: + except UnicodeDecodeError: record = ( outFile.readline() .decode(encoding=enc, errors="replace") @@ -965,7 +965,7 @@ def OnLayerPageChanged(self, event): pass if idCol: - winCol = self.FindWindowById(idCol) + self.FindWindowById(idCol) table = self.dbMgrData["mapDBInfo"].layers[self.selLayer]["table"] self.dbMgrData["mapDBInfo"].GetColumns(table) @@ -2687,7 +2687,6 @@ def OnTableItemDelete(self, event): tlist = self.FindWindowById(self.layerPage[self.selLayer]["tableData"]) item = tlist.GetFirstSelected() - countSelected = tlist.GetSelectedItemCount() if UserSettings.Get(group="atm", key="askOnDeleteRec", subkey="enabled"): # if the user select more columns to delete, all the columns name # will appear the the warning dialog diff --git a/gui/wxpython/dbmgr/dialogs.py b/gui/wxpython/dbmgr/dialogs.py index 757fde03cbf..26e6d876371 100644 --- a/gui/wxpython/dbmgr/dialogs.py +++ b/gui/wxpython/dbmgr/dialogs.py @@ -305,7 +305,6 @@ def OnReset(self, event=None): columns = self.mapDBInfo.tables[table] for idx in range(len(columns[key]["values"])): for name in columns.keys(): - type = columns[name]["type"] value = columns[name]["values"][idx] if value is None: value = "" diff --git a/gui/wxpython/dbmgr/sqlbuilder.py b/gui/wxpython/dbmgr/sqlbuilder.py index 92867b9ec82..c5552363d18 100644 --- a/gui/wxpython/dbmgr/sqlbuilder.py +++ b/gui/wxpython/dbmgr/sqlbuilder.py @@ -356,7 +356,6 @@ def _doLayout(self, modeChoices, showDbInfo=False): def OnUniqueValues(self, event, justsample=False): """Get unique values""" - vals = [] try: idx = self.list_columns.GetSelections()[0] column = self.list_columns.GetString(idx) @@ -418,9 +417,7 @@ def OnAddValue(self, event): idx = self.list_columns.GetSelections()[0] column = self.list_columns.GetString(idx) - ctype = self.dbInfo.GetTableDesc(self.dbInfo.GetTable(self.layer))[column][ - "type" - ] + self.dbInfo.GetTableDesc(self.dbInfo.GetTable(self.layer))[column]["type"] self._add(element="value", value=value) diff --git a/gui/wxpython/dbmgr/vinfo.py b/gui/wxpython/dbmgr/vinfo.py index afb0a716063..6b04ee7a64e 100644 --- a/gui/wxpython/dbmgr/vinfo.py +++ b/gui/wxpython/dbmgr/vinfo.py @@ -102,9 +102,6 @@ def SelectByPoint(self, queryCoords, qdist): """Get attributes by coordinates (all available layers) Return line id or None if no line is found""" - line = None - nselected = 0 - try: data = gs.vector_what( map=self.map, From 098cef32f82c7075d037bc7c462d549145000d7c Mon Sep 17 00:00:00 2001 From: mshukun Date: Thu, 29 Aug 2024 13:14:05 -0400 Subject: [PATCH 2/3] Update `.flake8` according to F841 fixes --- .flake8 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.flake8 b/.flake8 index 573debabe1c..18cea9165ce 100644 --- a/.flake8 +++ b/.flake8 @@ -52,11 +52,10 @@ per-file-ignores = gui/wxpython/core/settings.py: E722 gui/wxpython/core/watchdog.py: E402 gui/wxpython/datacatalog/tree.py: E731, E402 - gui/wxpython/dbmgr/base.py: E722, F841 - gui/wxpython/dbmgr/dialogs.py: F841, E722 - gui/wxpython/dbmgr/sqlbuilder.py: E722, F841 + gui/wxpython/dbmgr/base.py: E722 + gui/wxpython/dbmgr/dialogs.py: E722 + gui/wxpython/dbmgr/sqlbuilder.py: E722 gui/wxpython/dbmgr/manager.py: E722 - gui/wxpython/dbmgr/vinfo.py: F841 gui/wxpython/docs/wxgui_sphinx/conf.py: E402, W291 gui/wxpython/gcp/g.gui.gcp.py: F841 gui/wxpython/gcp/manager.py: F841, E722 From 1d903c8ad9403ea01b4e7673ae673a50f0aefe82 Mon Sep 17 00:00:00 2001 From: mshukun Date: Thu, 29 Aug 2024 16:05:58 -0400 Subject: [PATCH 3/3] Remove unused lines based on reviewed suggestions --- gui/wxpython/dbmgr/base.py | 1 - gui/wxpython/dbmgr/sqlbuilder.py | 4 ---- 2 files changed, 5 deletions(-) diff --git a/gui/wxpython/dbmgr/base.py b/gui/wxpython/dbmgr/base.py index 7fe62942fb3..66321fcafda 100644 --- a/gui/wxpython/dbmgr/base.py +++ b/gui/wxpython/dbmgr/base.py @@ -965,7 +965,6 @@ def OnLayerPageChanged(self, event): pass if idCol: - self.FindWindowById(idCol) table = self.dbMgrData["mapDBInfo"].layers[self.selLayer]["table"] self.dbMgrData["mapDBInfo"].GetColumns(table) diff --git a/gui/wxpython/dbmgr/sqlbuilder.py b/gui/wxpython/dbmgr/sqlbuilder.py index c5552363d18..36827698efc 100644 --- a/gui/wxpython/dbmgr/sqlbuilder.py +++ b/gui/wxpython/dbmgr/sqlbuilder.py @@ -414,10 +414,6 @@ def OnAddValue(self, event): idx = selection[0] value = self.list_values.GetString(idx) - idx = self.list_columns.GetSelections()[0] - column = self.list_columns.GetString(idx) - - self.dbInfo.GetTableDesc(self.dbInfo.GetTable(self.layer))[column]["type"] self._add(element="value", value=value)