Skip to content

Commit

Permalink
style: repeated-global (FURB154) (OSGeo#4048)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Jul 14, 2024
1 parent 7695805 commit b565924
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 82 deletions.
22 changes: 6 additions & 16 deletions gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@
#
# global variables
#
global src_map
global tgt_map
global maptype
global maptype, src_map, tgt_map

src_map = ""
tgt_map = {"raster": "", "vector": ""}
Expand Down Expand Up @@ -138,9 +136,7 @@ def __init__(self, parent, giface):
# mapset for xy map to georectify
self.newmapset = ""

global maptype
global src_map
global tgt_map
global maptype, src_map, tgt_map

# src_map = ''
# tgt_map = ''
Expand Down Expand Up @@ -875,8 +871,7 @@ def __init__(self, wizard, parent):

def OnSrcSelection(self, event):
"""Source map to display selected"""
global src_map
global maptype
global maptype, src_map

src_map = self.srcselection.GetValue()

Expand Down Expand Up @@ -912,8 +907,7 @@ def OnTgtVectSelection(self, event):
tgt_map["vector"] = self.tgtvectselection.GetValue()

def OnPageChanging(self, event=None):
global src_map
global tgt_map
global src_map, tgt_map

if event.GetDirection() and (src_map == ""):
GMessage(
Expand All @@ -925,9 +919,7 @@ def OnPageChanging(self, event=None):
self.parent.SwitchEnv("target")

def OnEnterPage(self, event=None):
global maptype
global src_map
global tgt_map
global maptype, src_map, tgt_map

self.srcselection.SetElementList(maptype)

Expand Down Expand Up @@ -3369,9 +3361,7 @@ def OnExtension(self, event):
self.parent.extension = self.ext_txt.GetValue()

def UpdateSettings(self):
global src_map
global tgt_map
global maptype
global maptype, src_map, tgt_map

layers = None

Expand Down
22 changes: 6 additions & 16 deletions gui/wxpython/image2target/ii2t_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@
#
# global variables
#
global src_map
global tgt_map
global maptype
global src_map, tgt_map, maptype

src_map = ""
tgt_map = {"raster": "", "vector": ""}
Expand Down Expand Up @@ -178,9 +176,7 @@ def __init__(self, parent, giface):
# mapset for xy map to georectify
self.newmapset = ""

global maptype
global src_map
global tgt_map
global maptype, src_map, tgt_map

# src_map = ''
# tgt_map = ''
Expand Down Expand Up @@ -879,8 +875,7 @@ def __init__(self, wizard, parent):

def OnSrcSelection(self, event):
"""Source map to display selected"""
global src_map
global maptype
global src_map, maptype

src_map = self.srcselection.GetValue()

Expand Down Expand Up @@ -916,8 +911,7 @@ def OnTgtVectSelection(self, event):
tgt_map["vector"] = self.tgtvectselection.GetValue()

def OnPageChanging(self, event=None):
global src_map
global tgt_map
global src_map, tgt_map

if event.GetDirection() and (src_map == ""):
GMessage(
Expand All @@ -929,9 +923,7 @@ def OnPageChanging(self, event=None):
self.parent.SwitchEnv("target")

def OnEnterPage(self, event=None):
global maptype
global src_map
global tgt_map
global maptype, src_map, tgt_map

self.srcselection.SetElementList(maptype)

Expand Down Expand Up @@ -3318,9 +3310,7 @@ def OnExtension(self, event):
self.parent.extension = self.ext_txt.GetValue()

def UpdateSettings(self):
global src_map
global tgt_map
global maptype
global src_map, tgt_map, maptype

layers = None

Expand Down
18 changes: 2 additions & 16 deletions gui/wxpython/location_wizard/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@
from grass.script import core as grass
from grass.exceptions import OpenError

global coordsys
global north
global south
global east
global west
global resolution
global wizerror
global translist
global coordsys, north, south, east, west, resolution, wizerror, translist

if globalvar.CheckWxVersion(version=[4, 1, 0]):
search_cancel_evt = wx.EVT_SEARCH_CANCEL
Expand Down Expand Up @@ -2539,14 +2532,7 @@ def __init__(self, parent, grassdatabase):
self.__cleanUp()

def __cleanUp(self):
global coordsys
global north
global south
global east
global west
global resolution
global wizerror
global translist
global coordsys, north, south, east, west, resolution, wizerror, translist

coordsys = None
north = None
Expand Down
12 changes: 3 additions & 9 deletions gui/wxpython/photo2image/ip2i_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
#
# global variables
#
global src_map
global tgt_map
global maptype
global src_map, tgt_map, maptype

src_map = ""
tgt_map = ""
Expand Down Expand Up @@ -95,9 +93,7 @@ class GCPWizard:
def __init__(
self, parent, giface, group, raster, raster1, camera, order, extension
):
global maptype
global src_map
global tgt_map
global maptype, src_map, tgt_map
maptype = "raster"
rendertype = "raster"
self.parent = parent # GMFrame
Expand Down Expand Up @@ -2406,9 +2402,7 @@ def OnExtension(self, event):
self.parent.extension = self.ext_txt.GetValue()

def UpdateSettings(self):
global src_map
global tgt_map
global maptype
global src_map, tgt_map, maptype

layers = None

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ ignore = [
"FBT003", # boolean-positional-value-in-call
"FURB118", # reimplemented-operator
"FURB152", # math-constant
"FURB154", # repeated-global
"I001", # unsorted-imports
"ISC003", # explicit-string-concatenation
"PERF203", # try-except-in-loop
Expand Down Expand Up @@ -389,7 +388,7 @@ ignore = [
"python/grass/temporal/univar_statistics.py" = ["INT002"]
"raster3d/r3.flow/testsuite/r3flow_test.py" = ["FLY002"]
"raster3d/r3.gradient/testsuite/r3gradient_test.py" = ["FLY002"]
"scripts/d.polar/d.polar.py" = ["INT002"]
"scripts/d.polar/d.polar.py" = ["FURB154", "INT002"]
"scripts/g.extension.all/g.extension.all.py" = ["INT002"]
"scripts/g.extension/g.extension.py" = ["INT002"]
"scripts/i.oif/i.oif.py" = ["INT003"]
Expand Down
3 changes: 1 addition & 2 deletions python/grass/script/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,7 @@ def vector_what(
return data

# lazy import
global json
global orderedDict
global json, orderedDict
if json is None:
import json
if orderedDict is None:
Expand Down
30 changes: 9 additions & 21 deletions python/grass/temporal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ def stop_subprocesses():
"""Stop the messenger and C-interface subprocesses
that are started by tgis.init()
"""
global message_interface
global c_library_interface
global message_interface, c_library_interface
if message_interface:
message_interface.stop()
if c_library_interface:
Expand All @@ -473,8 +472,7 @@ def get_available_temporal_mapsets():
:returns: A dictionary, mapset names are keys, the tuple (driver,
database) are the values
"""
global c_library_interface
global message_interface
global c_library_interface, message_interface

mapsets = c_library_interface.available_mapsets()

Expand Down Expand Up @@ -562,17 +560,11 @@ def init(raise_fatal_error=False, skip_db_version_check=False):
"""
# We need to set the correct database backend and several global variables
# from the GRASS mapset specific environment variables of g.gisenv and t.connect
global tgis_backend
global tgis_database
global tgis_database_string
global tgis_dbmi_paramstyle
global tgis_db_version
global raise_on_error
global enable_mapset_check
global enable_timestamp_write
global current_mapset
global current_location
global current_gisdbase
global tgis_backend, tgis_database, tgis_database_string # noqa: FURB154
global tgis_dbmi_paramstyle, tgis_db_version # noqa: FURB154
global raise_on_error # noqa: FURB154
global enable_mapset_check, enable_timestamp_write # noqa: FURB154
global current_mapset, current_location, current_gisdbase # noqa: FURB154

raise_on_error = raise_fatal_error

Expand Down Expand Up @@ -846,10 +838,7 @@ def create_temporal_database(dbif):
:param dbif: The database interface to be used
"""
global tgis_backend
global tgis_version
global tgis_db_version
global tgis_database_string
global tgis_backend, tgis_version, tgis_db_version, tgis_database_string

template_path = get_sql_template_path()
msgr = get_tgis_message_interface()
Expand Down Expand Up @@ -977,8 +966,7 @@ def upgrade_temporal_database(dbif):
:param dbif: The database interface to be used
"""
global tgis_database_string
global tgis_db_version
global tgis_database_string, tgis_db_version

metadata = get_tgis_metadata(dbif)

Expand Down

0 comments on commit b565924

Please sign in to comment.