Skip to content

Commit

Permalink
Merge branch 'main' into tests-unused-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Oct 23, 2024
2 parents fafd964 + 930d59a commit 4a719e3
Show file tree
Hide file tree
Showing 147 changed files with 750 additions and 874 deletions.
11 changes: 4 additions & 7 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ per-file-ignores =
doc/python/m.distance.py: E501
gui/scripts/d.wms.py: E501
gui/wxpython/image2target/g.gui.image2target.py: E501
gui/wxpython/modules/*: F841, E722
gui/wxpython/nviz/*: E722, F403, F405
gui/wxpython/photo2image/*: F841, E722, E265
gui/wxpython/photo2image/g.gui.photo2image.py: E501, F841
gui/wxpython/nviz/*: E722
gui/wxpython/photo2image/*: E722
gui/wxpython/photo2image/g.gui.photo2image.py: E501
gui/wxpython/psmap/*: F841, E266, E722
gui/wxpython/vdigit/*: F841, E722, F405, F403
gui/wxpython/animation/g.gui.animation.py: E501
Expand Down Expand Up @@ -105,14 +104,12 @@ per-file-ignores =
scripts/i.pansharpen/i.pansharpen.py: E722, E501
scripts/r.in.srtm/r.in.srtm.py: E722
scripts/r.fillnulls/r.fillnulls.py: E722
scripts/d.rast.edit/d.rast.edit.py: E722
scripts/v.what.strds/v.what.strds.py: E501
# Line too long (esp. module interface definitions)
scripts/*/*.py: E501
temporal/t.rast.to.vect/t.rast.to.vect.py: E501
temporal/t.vect.algebra/t.vect.algebra.py: E501
# ## used (##% key: r etc)
temporal/t.rast.what/t.rast.what.py: E265, E266, E501
temporal/t.rast.what/t.rast.what.py: E501
# Line too long (esp. module interface definitions)
temporal/*/*.py: E501

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
if: ${{ matrix.language == 'c-cpp' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
Expand All @@ -81,6 +81,6 @@ jobs:
run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/python-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
path: bandit.sarif

- name: Upload SARIF File into Security Tab
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
with:
sarif_file: bandit.sarif

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ARG GUI=without

FROM ubuntu:22.04@sha256:58b87898e82351c6cf9cf5b9f3c20257bb9e2dcf33af051e12ce532d7f94e3fe as common_start
FROM ubuntu:22.04@sha256:0e5e4a57c2499249aafc3b40fcd541e9a456aab7296681a3994d631587203f97 as common_start

LABEL authors="Carmen Tawalika,Markus Neteler,Anika Weinmann,Stefan Blumentrath"
LABEL maintainer="tawalika@mundialis.de,neteler@mundialis.de,weinmann@mundialis.de"
Expand Down
6 changes: 3 additions & 3 deletions db/db.login/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ int main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}

if (db_set_login2(driver->answer, database->answer, user->answer,
password->answer, host->answer, port->answer,
G_get_overwrite()) == DB_FAILED) {
if (db_set_login(driver->answer, database->answer, user->answer,
password->answer, host->answer, port->answer,
G_get_overwrite()) == DB_FAILED) {
G_fatal_error(_("Unable to set user/password"));
}

Expand Down
2 changes: 1 addition & 1 deletion db/drivers/mysql/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int db__driver_open_database(dbHandle *handle)
connpar.host, connpar.port, connpar.dbname, connpar.user,
connpar.password);

db_get_login2("mysql", name, &user, &password, &host, &port);
db_get_login("mysql", name, &user, &password, &host, &port);

connection = mysql_init(NULL);
res =
Expand Down
4 changes: 2 additions & 2 deletions db/drivers/postgres/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int db__driver_open_database(dbHandle *handle)
return DB_FAILED;
}

db_get_login2("pg", name, &user, &password, &host, &port);
db_get_login("pg", name, &user, &password, &host, &port);

pg_conn = PQsetdbLogin(host, port, pgconn.options, pgconn.tty,
pgconn.dbname, user, password);
Expand Down Expand Up @@ -241,7 +241,7 @@ int create_delete_db(dbHandle *handle, int create)
pgconn.host, pgconn.port, pgconn.options, pgconn.tty, pgconn.dbname,
pgconn.user, pgconn.password, pgconn.host, pgconn.port,
pgconn.schema);
db_get_login2("pg", template_db, &user, &password, &host, &port);
db_get_login("pg", template_db, &user, &password, &host, &port);

pg_conn = PQsetdbLogin(host, port, pgconn.options, pgconn.tty,
pgconn.dbname, user, password);
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/postgres/listdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int db__driver_list_databases(dbString *dbpath, int npaths, dbHandle **dblist,
pgconn.dbname, pgconn.user, pgconn.password, pgconn.host,
pgconn.port, pgconn.options, pgconn.tty);

db_get_login2("pg", NULL, &user, &passwd, &host, &port);
db_get_login("pg", NULL, &user, &passwd, &host, &port);
G_debug(1, "user = %s, passwd = %s", user, passwd ? "xxx" : "");

if (user || passwd) {
Expand Down
5 changes: 1 addition & 4 deletions doc/python/raster_example_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
sys.exit("You must be in GRASS GIS to run this program")

# parse command line arguments, prompt user for a raster map name if one wasn't given
if len(sys.argv) == 2:
input = sys.argv[1]
else:
input = input("Name of raster map? ")
input = sys.argv[1] if len(sys.argv) == 2 else input("Name of raster map? ")

# initialize GRASS library
G_gisinit("")
Expand Down
5 changes: 1 addition & 4 deletions doc/python/vector_example_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
if "GISBASE" not in os.environ:
sys.exit("You must be in GRASS GIS to run this program.")

if len(sys.argv) == 2:
input = sys.argv[1]
else:
input = input("Name of vector map? ")
input = sys.argv[1] if len(sys.argv) == 2 else input("Name of vector map? ")

# initialize GRASS library
G_gisinit("")
Expand Down
2 changes: 1 addition & 1 deletion docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ARG GUI=without

FROM ubuntu:22.04@sha256:58b87898e82351c6cf9cf5b9f3c20257bb9e2dcf33af051e12ce532d7f94e3fe as common_start
FROM ubuntu:22.04@sha256:0e5e4a57c2499249aafc3b40fcd541e9a456aab7296681a3994d631587203f97 as common_start

LABEL authors="Carmen Tawalika,Markus Neteler,Anika Weinmann,Stefan Blumentrath"
LABEL maintainer="tawalika@mundialis.de,neteler@mundialis.de,weinmann@mundialis.de"
Expand Down
2 changes: 1 addition & 1 deletion docker/ubuntu_wxgui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04@sha256:58b87898e82351c6cf9cf5b9f3c20257bb9e2dcf33af051e12ce532d7f94e3fe
FROM ubuntu:22.04@sha256:0e5e4a57c2499249aafc3b40fcd541e9a456aab7296681a3994d631587203f97

LABEL authors="Carmen Tawalika,Markus Neteler,Anika Weinmann,Tomas Zigo"
LABEL maintainer="tawalika@mundialis.de,neteler@mundialis.de,weinmann@mundialis.de"
Expand Down
1 change: 0 additions & 1 deletion gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,6 @@ def _processComments(self):
"size": size,
"text": text,
"id": int(node.get("id", -1)),
"text": text,
}
)

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/iclass/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def ActivateSecondMap(self, event=None):

def GetMapToolbar(self):
"""Returns toolbar with zooming tools"""
return self.toolbars["iClassMap"] if "iClassMap" in self.toolbars else None
return self.toolbars.get("iClassMap", None)

def GetClassColor(self, cat):
"""Get class color as string
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/mapdisp/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ def SetProperties(

def GetMapToolbar(self):
"""Returns toolbar with zooming tools"""
return self.toolbars["map"] if "map" in self.toolbars else None
return self.toolbars.get("map", None)

def GetDialog(self, name):
"""Get selected dialog if exist"""
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/mapswipe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,15 @@ class _onDone:
we are pasting together 2 rendered images, so
we need to know when both are finished."""

def __init__(self2):
def __init__(self2): # noqa: N805
self2.called = 0

def __call__(self2):
def __call__(self2): # noqa: N805
self2.called += 1
if self2.called == 2:
self2.process()

def process(self2):
def process(self2): # noqa: N805
# create empty white image - needed for line
im = wx.Image(width, height)
im.Replace(0, 0, 0, 255, 255, 255)
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/modules/colorrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def LoadRules(self):
else:
value = float(self.ruleslines[item][self.attributeType])
self.mainPanel.FindWindowById(item + 2000).SetValue(value)
except:
except Exception:
continue

if message:
Expand Down Expand Up @@ -407,7 +407,7 @@ def _initLayer(self):
layer = sel
else:
layer = self.layerTree.FindItemByData(key="type", value=self.mapType)
except:
except (AttributeError, TypeError):
layer = None
if layer:
mapLayer = self.layerTree.GetLayerInfo(layer, key="maplayer")
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/modules/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def UpdateHistDone(self):
return
try:
id = self.imagedict[self.img]
except:
except KeyError:
return

# paint images to PseudoDC
Expand Down Expand Up @@ -524,7 +524,7 @@ def OnCloseWindow(self, event):
"""
try:
self.propwin.Close(True)
except:
except Exception:
pass
self.Map.Clean()
self.Destroy()
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/modules/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def OnRun(self, event):
if nBandsStr:
try:
nBands = int(nBandsStr.rstrip("\n"))
except:
except ValueError:
pass
if nBands < 0:
GWarning(_("Unable to determine number of raster bands"), parent=self)
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/modules/mcalc_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def _addSomething(self, what):
if newmcalcstr[-1] != " ":
newmcalcstr += " "
position_offset += 1
except:
except IndexError:
pass

newmcalcstr += what
Expand All @@ -617,7 +617,7 @@ def _addSomething(self, what):
try:
if newmcalcstr[-1] != " " and mcalcstr[position] != " ":
newmcalcstr += " "
except:
except IndexError:
newmcalcstr += " "

newmcalcstr += mcalcstr[position:]
Expand All @@ -632,7 +632,7 @@ def _addSomething(self, what):
try:
if newmcalcstr[position + position_offset] == " ":
position_offset += 1
except:
except IndexError:
pass

self.text_mcalc.SetInsertionPoint(position + position_offset)
Expand Down
Loading

0 comments on commit 4a719e3

Please sign in to comment.