Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Fixes unnecessary-collection-call (C408) for empty collections #3945

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui/wxpython/animation/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(
self._addPanes()
self._mgr.Update()

self.dialogs = dict()
self.dialogs = {}
self.dialogs["speed"] = None
self.dialogs["preferences"] = None

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/animation/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def SetCmds3D(self, cmds, region):
def _getUniqueCmds(self):
"""Returns list of unique commands.
Takes into account the region assigned."""
unique = list()
unique = []
for cmdList, region in zip(self._cmdsForComposition, self._regions):
for cmd in cmdList:
if region:
Expand Down
20 changes: 10 additions & 10 deletions gui/wxpython/core/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(
self.name = name

if self.type == "command":
self.cmd = list()
self.cmd = []
for c in cmd:
self.cmd.append(cmdlist_to_tuple(c))
else:
Expand Down Expand Up @@ -670,9 +670,9 @@ def OnRenderDone(self, env):
"""
stopTime = time.time()

maps = list()
masks = list()
opacities = list()
maps = []
masks = []
opacities = []

# TODO: g.pnmcomp is now called every time
# even when only overlays are rendered
Expand Down Expand Up @@ -824,16 +824,16 @@ def __init__(self, gisrc=None):
"""
Debug.msg(1, "Map.__init__(): gisrc=%s" % gisrc)
# region/extent settings
self.wind = dict() # WIND settings (wind file)
self.region = dict() # region settings (g.region)
self.wind = {} # WIND settings (wind file)
self.region = {} # region settings (g.region)
self.width = 640 # map width
self.height = 480 # map height

# list of layers
self.layers = list() # stack of available GRASS layer
self.layers = [] # stack of available GRASS layer

self.overlays = list() # stack of available overlays
self.ovlookup = dict() # lookup dictionary for overlay items and overlays
self.overlays = [] # stack of available overlays
self.ovlookup = {} # lookup dictionary for overlay items and overlays

# path to external gisrc
self.gisrc = gisrc
Expand Down Expand Up @@ -866,7 +866,7 @@ def GetProjInfo(self):

def _projInfo(self):
"""Return region projection and map units information"""
projinfo = dict()
projinfo = {}
if not grass.find_program("g.proj", "--help"):
sys.exit(
_("GRASS tool '%s' not found. Unable to start map " "display window.")
Expand Down
10 changes: 3 additions & 7 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,9 +1065,7 @@ def Get(self, group, key=None, subkey=None, settings_type="user"):
else:
return settings[group][key]
else:
if isinstance(subkey, type(tuple())) or isinstance(
subkey, type(list())
):
if isinstance(subkey, tuple) or isinstance(subkey, list):
return settings[group][key][subkey[0]][subkey[1]]
else:
return settings[group][key][subkey]
Expand Down Expand Up @@ -1104,9 +1102,7 @@ def Set(self, group, value, key=None, subkey=None, settings_type="user"):
else:
settings[group][key] = value
else:
if isinstance(subkey, type(tuple())) or isinstance(
subkey, type(list())
):
if isinstance(subkey, tuple) or isinstance(subkey, list):
settings[group][key][subkey[0]][subkey[1]] = value
else:
settings[group][key][subkey] = value
Expand Down Expand Up @@ -1201,7 +1197,7 @@ def Reset(self, key=None):


def GetDisplayVectSettings():
settings = list()
settings = []
if not UserSettings.Get(
group="vectorLayer", key="featureColor", subkey=["transparent", "enabled"]
):
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/core/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class BaseUnits:
def __init__(self):
self._units = dict()
self._units = {}
self._units["length"] = {
0: {"key": "mu", "label": _("map units")},
1: {"key": "me", "label": _("meters")},
Expand All @@ -53,7 +53,7 @@ def GetUnitsList(self, type):

:return: list of units labels
"""
result = list()
result = []
try:
keys = sorted(self._units[type].keys())
for idx in keys:
Expand Down
18 changes: 9 additions & 9 deletions gui/wxpython/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def GetLayerNameFromCmd(dcmd, fullyQualified=False, param=None, layerType=None):
elif "d.graph" in dcmd[0]:
mapname = "graph"
else:
params = list()
params = []
for idx in range(len(dcmd)):
try:
p, v = dcmd[idx].split("=", 1)
Expand Down Expand Up @@ -186,7 +186,7 @@ def GetLayerNameFromCmd(dcmd, fullyQualified=False, param=None, layerType=None):
if i in mapsets and mapsets[i]:
dcmd[i] += "@" + mapsets[i]

maps = list()
maps = []
ogr = False
for i, p, v in params:
if v.lower().rfind("@ogr") > -1:
Expand Down Expand Up @@ -321,7 +321,7 @@ def ListSortLower(list):

def GetVectorNumberOfLayers(vector):
"""Get list of all vector layers"""
layers = list()
layers = []
if not vector:
return layers

Expand Down Expand Up @@ -514,7 +514,7 @@ def ReadEpsgCodes():

:return: dictionary of EPSG code
"""
epsgCodeDict = dict()
epsgCodeDict = {}

ret = RunCommand("g.proj", read=True, list_codes="EPSG")

Expand Down Expand Up @@ -570,7 +570,7 @@ def GetListOfLocations(dbase):

:return: list of locations (sorted)
"""
listOfLocations = list()
listOfLocations = []

try:
for location in glob.glob(os.path.join(dbase, "*")):
Expand Down Expand Up @@ -598,7 +598,7 @@ def GetListOfMapsets(dbase, location, selectable=False):

:return: list of mapsets - sorted (PERMANENT first)
"""
listOfMapsets = list()
listOfMapsets = []

if selectable:
ret = RunCommand(
Expand All @@ -625,7 +625,7 @@ def GetColorTables():
"""Get list of color tables"""
ret = RunCommand("r.colors", read=True, flags="l")
if not ret:
return list()
return []

return ret.splitlines()

Expand Down Expand Up @@ -835,8 +835,8 @@ def StoreEnvVariable(key, value=None, envFile=None):
)

# read env file
environ = dict()
lineSkipped = list()
environ = {}
lineSkipped = []
if os.path.exists(envFile):
try:
fd = open(envFile)
Expand Down
12 changes: 6 additions & 6 deletions gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def __processLayer(self, layer):

:param layer: tree node
"""
cmd = list()
cmd = []

#
# layer attributes (task) - 2D settings
Expand Down Expand Up @@ -344,7 +344,7 @@ def __processOverlay(self, node_overlay):
Process overlay item
:param overlay: tree node
"""
cmd = list()
cmd = []

cmd.append(node_overlay.get("name", "unknown"))

Expand Down Expand Up @@ -374,12 +374,12 @@ def __processLayerVdigit(self, node_vdigit):
:param node_vdigit: vdigit node
"""
# init nviz layer properties
vdigit = dict()
vdigit = {}
for node in node_vdigit.findall("geometryAttribute"):
if "geomAttr" not in vdigit:
vdigit["geomAttr"] = dict()
vdigit["geomAttr"] = {}
type = node.get("type")
vdigit["geomAttr"][type] = dict()
vdigit["geomAttr"][type] = {}
vdigit["geomAttr"][type]["column"] = node.get("column") # required
# default map units
vdigit["geomAttr"][type]["units"] = node.get("units", "mu")
Expand Down Expand Up @@ -736,7 +736,7 @@ def __processLayerNvizNode(self, node, tag, cast, dc=None):
else:
value = None
if dc:
dc[tag] = dict()
dc[tag] = {}
dc[tag]["value"] = value
else:
return value
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/datacatalog/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,13 @@ def _reloadGrassDBNode(self, grassdb_node):
except NotImplementedError:
nprocs = 1

results = dict()
results = {}
errors = []
location_nodes = []
all_location_nodes = []
nlocations = len(locations)
for location in locations:
results[location] = dict()
results[location] = {}
varloc = self._model.AppendNode(
parent=grassdb_node, data=dict(type="location", name=location)
)
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ def OnDataItemEdit(self, event):

if dlg.ShowModal() == wx.ID_OK:
values = dlg.GetValues() # string
updateList = list()
updateList = []
try:
for i in range(len(values)):
if i == keyId: # skip key column
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/dbmgr/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def GetValues(self, columns=None):

If columns is given (list), return only values of given columns.
"""
valueList = list()
valueList = []
for labelId, ctypeId, valueId in self.widgets:
column = self.FindWindowById(labelId).GetLabel()
if columns is None or column in columns:
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/dbmgr/vinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def SelectByPoint(self, queryCoords, qdist):
return None

# process attributes
ret = dict()
ret = {}
for key in ["Category", "Layer", "Table", "Id"]:
ret[key] = list()
ret[key] = []

for record in data:
if "Table" not in record:
Expand Down
10 changes: 5 additions & 5 deletions gui/wxpython/gmodeler/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def GetNewShapePos(self, yoffset=50):

def GetShapesSelected(self):
"""Get list of selected shapes"""
selected = list()
selected = []
diagram = self.GetDiagram()
for shape in diagram.GetShapeList():
if shape.Selected():
Expand Down Expand Up @@ -219,7 +219,7 @@ def OnProperties(self, event=None):
shape.SetLabel(dlg.GetCondition())
model = self.frame.GetModel()
ids = dlg.GetItems()
alist = list()
alist = []
for aId in ids["unchecked"]:
action = model.GetItem(aId, objType=ModelAction)
if action:
Expand All @@ -244,7 +244,7 @@ def OnProperties(self, event=None):
model = self.frame.GetModel()
ids = dlg.GetItems()
for b in ids.keys():
alist = list()
alist = []
for aId in ids[b]["unchecked"]:
action = model.GetItem(aId, objType=ModelAction)
action.UnSetBlock(shape)
Expand Down Expand Up @@ -295,7 +295,7 @@ def OnEndSize(self, x, y):
def OnRightClick(self, x, y, keys=0, attachment=0):
"""Right click -> pop-up menu"""
if not hasattr(self, "popupID"):
self.popupID = dict()
self.popupID = {}
for key in (
"remove",
"enable",
Expand Down Expand Up @@ -445,7 +445,7 @@ def _onSelectShape(self, shape, append=False):
shape.Select(False, dc)
else:
shapeList = canvas.GetDiagram().GetShapeList()
toUnselect = list()
toUnselect = []

if not append:
for s in shapeList:
Expand Down
Loading
Loading