From a3543cd83886835268fc43b39ac1c9748b493faf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Edouard=20Choini=C3=A8re?=
<27212526+echoix@users.noreply.github.com>
Date: Wed, 10 Jul 2024 22:51:15 -0400
Subject: [PATCH] style: Fix if-exp-instead-of-or-operator (FURB110) (#4013)
---
gui/wxpython/core/treemodel.py | 4 ++--
gui/wxpython/datacatalog/tree.py | 2 +-
gui/wxpython/gui_core/dialogs.py | 2 +-
gui/wxpython/history/tree.py | 2 +-
gui/wxpython/rdigit/g.gui.rdigit.py | 2 +-
gui/wxpython/startup/guiutils.py | 2 +-
man/parser_standard_options.py | 2 +-
pyproject.toml | 1 -
python/grass/pygrass/modules/grid/grid.py | 2 +-
python/grass/pygrass/modules/grid/split.py | 6 +++---
python/grass/pygrass/modules/shortcuts.py | 2 +-
python/grass/pygrass/raster/__init__.py | 8 ++++----
python/grass/pygrass/raster/abstract.py | 2 +-
python/grass/pygrass/shell/conversion.py | 6 +++---
python/grass/pygrass/utils.py | 2 +-
python/grass/pygrass/vector/__init__.py | 8 ++++----
python/grass/pygrass/vector/abstract.py | 8 ++++----
python/grass/pygrass/vector/basic.py | 10 +++-------
python/grass/pygrass/vector/find.py | 8 ++++----
python/grass/pygrass/vector/geometry.py | 20 +++++++++----------
python/grass/pygrass/vector/table.py | 14 ++++++-------
.../tests/grass_script_core_location_test.py | 2 +-
scripts/db.in.ogr/db.in.ogr.py | 2 +-
scripts/g.extension/g.extension.py | 2 +-
utils/mkhtml.py | 9 +++------
25 files changed, 60 insertions(+), 68 deletions(-)
diff --git a/gui/wxpython/core/treemodel.py b/gui/wxpython/core/treemodel.py
index 4c5de36f701..c891dafe25c 100644
--- a/gui/wxpython/core/treemodel.py
+++ b/gui/wxpython/core/treemodel.py
@@ -95,7 +95,7 @@ def AppendNode(self, parent, **kwargs):
def SearchNodes(self, parent=None, **kwargs):
"""Search nodes according to specified attributes."""
nodes = []
- parent = parent if parent else self.root
+ parent = parent or self.root
self._searchNodes(node=parent, foundNodes=nodes, **kwargs)
return nodes
@@ -291,7 +291,7 @@ class ModuleNode(DictNode):
def __init__(self, label=None, data=None):
super().__init__(data=data)
- self._label = label if label else ""
+ self._label = label or ""
if not data:
self.data = {}
diff --git a/gui/wxpython/datacatalog/tree.py b/gui/wxpython/datacatalog/tree.py
index 542282802be..0d8b0563c47 100644
--- a/gui/wxpython/datacatalog/tree.py
+++ b/gui/wxpython/datacatalog/tree.py
@@ -181,7 +181,7 @@ def __init__(self, data=None):
def label(self):
data = self.data
if data["type"] == "mapset":
- owner = data["owner"] if data["owner"] else _("name unknown")
+ owner = data["owner"] or _("name unknown")
if data["current"]:
return _("{name} (current)").format(**data)
elif data["is_different_owner"] and data["lock"]:
diff --git a/gui/wxpython/gui_core/dialogs.py b/gui/wxpython/gui_core/dialogs.py
index 6c0c75f5507..167a48ce6bb 100644
--- a/gui/wxpython/gui_core/dialogs.py
+++ b/gui/wxpython/gui_core/dialogs.py
@@ -2334,7 +2334,7 @@ def __init__(
label = StaticText(self, label=message)
sizer.Add(label, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=10)
- hyperlinkLabel = hyperlinkLabel if hyperlinkLabel else hyperlink
+ hyperlinkLabel = hyperlinkLabel or hyperlink
hyperlinkCtrl = HyperlinkCtrl(
self,
id=wx.ID_ANY,
diff --git a/gui/wxpython/history/tree.py b/gui/wxpython/history/tree.py
index 2ab158c45c5..0e9d75870aa 100644
--- a/gui/wxpython/history/tree.py
+++ b/gui/wxpython/history/tree.py
@@ -279,7 +279,7 @@ def _initHistoryModel(self):
data={
"type": COMMAND,
"name": entry["command"].strip(),
- "timestamp": timestamp if timestamp else None,
+ "timestamp": timestamp or None,
"status": status,
},
)
diff --git a/gui/wxpython/rdigit/g.gui.rdigit.py b/gui/wxpython/rdigit/g.gui.rdigit.py
index 0a9a72e4acb..ac68525cd6e 100755
--- a/gui/wxpython/rdigit/g.gui.rdigit.py
+++ b/gui/wxpython/rdigit/g.gui.rdigit.py
@@ -116,7 +116,7 @@ def __init__(
self._mapObj = self.GetMap()
# load raster map
- self._addLayer(name=new_map if new_map else edit_map)
+ self._addLayer(name=new_map or edit_map)
# switch toolbar
self.AddToolbar("rdigit", fixed=True)
diff --git a/gui/wxpython/startup/guiutils.py b/gui/wxpython/startup/guiutils.py
index baa74fd6b68..8bf4debef66 100644
--- a/gui/wxpython/startup/guiutils.py
+++ b/gui/wxpython/startup/guiutils.py
@@ -586,7 +586,7 @@ def can_switch_mapset_interactive(guiparent, grassdb, location, mapset):
if is_mapset_locked(mapset_path):
info = get_mapset_lock_info(mapset_path)
- user = info["owner"] if info["owner"] else _("unknown")
+ user = info["owner"] or _("unknown")
lockpath = info["lockpath"]
timestamp = info["timestamp"]
diff --git a/man/parser_standard_options.py b/man/parser_standard_options.py
index dd9c7dd6a35..87ffc6c4979 100644
--- a/man/parser_standard_options.py
+++ b/man/parser_standard_options.py
@@ -218,7 +218,7 @@ def _repr_html_(self):
)
args = parser.parse_args()
- cfile = args.text if args.text else urlopen(args.url, proxies=None)
+ cfile = args.text or urlopen(args.url, proxies=None)
options = OptTable(parse_options(cfile.readlines(), startswith=args.startswith))
outform = args.format
diff --git a/pyproject.toml b/pyproject.toml
index 7bce17922b2..268996612b7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -158,7 +158,6 @@ ignore = [
"FURB101", # read-whole-file
"FURB103", # write-whole-file.
"FURB105", # print-empty-string
- "FURB110", # if-exp-instead-of-or-operator
"FURB116", # f-string-number-format
"FURB116", # f-string-number-format
"FURB118", # reimplemented-operator
diff --git a/python/grass/pygrass/modules/grid/grid.py b/python/grass/pygrass/modules/grid/grid.py
index 911ecf21be1..1163a8f3b6d 100644
--- a/python/grass/pygrass/modules/grid/grid.py
+++ b/python/grass/pygrass/modules/grid/grid.py
@@ -469,7 +469,7 @@ def __init__(
self.height = height
self.overlap = overlap
self.processes = processes
- self.region = region if region else Region()
+ self.region = region or Region()
self.start_row = start_row
self.start_col = start_col
self.out_prefix = out_prefix
diff --git a/python/grass/pygrass/modules/grid/split.py b/python/grass/pygrass/modules/grid/split.py
index ea20a216e8e..afd747090b0 100644
--- a/python/grass/pygrass/modules/grid/split.py
+++ b/python/grass/pygrass/modules/grid/split.py
@@ -93,7 +93,7 @@ def split_region_in_overlapping_tiles(region=None, width=100, height=100, overla
[[Bbox(1350.0, 640.0, 1010.0, 0.0), Bbox(1350.0, 640.0, 1500.0, 990.0)],
[Bbox(660.0, 0.0, 1010.0, 0.0), Bbox(660.0, 0.0, 1500.0, 990.0)]]
"""
- reg = region if region else Region()
+ reg = region or Region()
ncols = (reg.cols + width - 1) // width
nrows = (reg.rows + height - 1) // height
box_list = []
@@ -118,7 +118,7 @@ def split_region_tiles(region=None, width=100, height=100):
:param height: the width of tiles
:type height: int
"""
- reg = region if region else Region()
+ reg = region or Region()
ncols = (reg.cols + width - 1) // width
nrows = (reg.rows + height - 1) // height
box_list = []
@@ -142,7 +142,7 @@ def get_overlap_region_tiles(region=None, width=100, height=100, overlap=0):
:param overlap: the value of overlap between tiles
:type overlap: int
"""
- reg = region if region else Region()
+ reg = region or Region()
ncols = (reg.cols + width - 1) // width
nrows = (reg.rows + height - 1) // height
box_list = []
diff --git a/python/grass/pygrass/modules/shortcuts.py b/python/grass/pygrass/modules/shortcuts.py
index bde3142e54c..f7fbdf7f04c 100644
--- a/python/grass/pygrass/modules/shortcuts.py
+++ b/python/grass/pygrass/modules/shortcuts.py
@@ -59,7 +59,7 @@ class MetaModule:
def __init__(self, prefix, cls=None):
self.prefix = prefix
- self.cls = cls if cls else Module
+ self.cls = cls or Module
def __dir__(self):
return [
diff --git a/python/grass/pygrass/raster/__init__.py b/python/grass/pygrass/raster/__init__.py
index c10140483d5..2fe95602fdd 100644
--- a/python/grass/pygrass/raster/__init__.py
+++ b/python/grass/pygrass/raster/__init__.py
@@ -187,8 +187,8 @@ def open(self, mode=None, mtype=None, overwrite=None):
* self._rows and self._cols
"""
- self.mode = mode if mode else self.mode
- self.mtype = mtype if mtype else self.mtype
+ self.mode = mode or self.mode
+ self.mtype = mtype or self.mtype
self.overwrite = overwrite if overwrite is not None else self.overwrite
if self.mode == "r":
@@ -509,8 +509,8 @@ def open(self, mode=None, mtype=None, overwrite=None):
self._rows = libraster.Rast_window_rows()
self._cols = libraster.Rast_window_cols()
- self.mode = mode if mode else self.mode
- self.mtype = mtype if mtype else self.mtype
+ self.mode = mode or self.mode
+ self.mtype = mtype or self.mtype
self.overwrite = overwrite if overwrite is not None else self.overwrite
if self.exist():
diff --git a/python/grass/pygrass/raster/abstract.py b/python/grass/pygrass/raster/abstract.py
index fa29a662500..616964d8f7b 100644
--- a/python/grass/pygrass/raster/abstract.py
+++ b/python/grass/pygrass/raster/abstract.py
@@ -431,7 +431,7 @@ def exist(self):
if self.name:
if self.mapset == "":
mapset = utils.get_mapset_raster(self.name, self.mapset)
- self.mapset = mapset if mapset else ""
+ self.mapset = mapset or ""
return bool(mapset)
return bool(utils.get_mapset_raster(self.name, self.mapset))
else:
diff --git a/python/grass/pygrass/shell/conversion.py b/python/grass/pygrass/shell/conversion.py
index 76802c08ce1..b30acc3b545 100644
--- a/python/grass/pygrass/shell/conversion.py
+++ b/python/grass/pygrass/shell/conversion.py
@@ -83,12 +83,12 @@ def dict2html(
def fun(x):
return x
- keys = keys if keys else sorted(dic.keys())
+ keys = keys or sorted(dic.keys())
header = "
" % border if border else ""
kd = "<%s>%s%s>" % (kdec, kfmt, kdec) if kdec else kfmt
vd = "<%s>%s%s>" % (vdec, vfmt, vdec) if vdec else vfmt
- kfun = kfun if kfun else fun
- vfun = vfun if vfun else fun
+ kfun = kfun or fun
+ vfun = vfun or fun
content = [dcont.format(key=kd % kfun(k), value=vd % vfun(dic[k])) for k in keys]
return "\n".join(
[
diff --git a/python/grass/pygrass/utils.py b/python/grass/pygrass/utils.py
index 02719c3730f..9727ed26791 100644
--- a/python/grass/pygrass/utils.py
+++ b/python/grass/pygrass/utils.py
@@ -348,7 +348,7 @@ def r_export(rast, output="", fmt="png", **kargs):
from grass.pygrass.modules import Module
if rast.exist():
- output = output if output else "%s_%s.%s" % (rast.name, rast.mapset, fmt)
+ output = output or "%s_%s.%s" % (rast.name, rast.mapset, fmt)
Module(
"r.out.%s" % fmt,
input=rast.fullname(),
diff --git a/python/grass/pygrass/vector/__init__.py b/python/grass/pygrass/vector/__init__.py
index c298391cc90..7869b1a29b5 100644
--- a/python/grass/pygrass/vector/__init__.py
+++ b/python/grass/pygrass/vector/__init__.py
@@ -310,9 +310,9 @@ def __getitem__(self, key):
return [
self.read(indx)
for indx in range(
- key.start if key.start else 1,
- key.stop if key.stop else len(self),
- key.step if key.step else 1,
+ key.start or 1,
+ key.stop or len(self),
+ key.step or 1,
)
]
elif isinstance(key, int):
@@ -509,7 +509,7 @@ def cat(self, cat_id, vtype, layer=None, generator=False, geo=None):
ilist = Ilist()
libvect.Vect_cidx_find_all(
self.c_mapinfo,
- layer if layer else self.layer,
+ layer or self.layer,
Obj.gtype,
cat_id,
ilist.c_ilist,
diff --git a/python/grass/pygrass/vector/abstract.py b/python/grass/pygrass/vector/abstract.py
index 9f8d5dc90b2..de4f74b9460 100644
--- a/python/grass/pygrass/vector/abstract.py
+++ b/python/grass/pygrass/vector/abstract.py
@@ -299,7 +299,7 @@ def exist(self):
if self.name:
if self.mapset == "":
mapset = utils.get_mapset_vector(self.name, self.mapset)
- self.mapset = mapset if mapset else ""
+ self.mapset = mapset or ""
return bool(mapset)
return bool(utils.get_mapset_vector(self.name, self.mapset))
else:
@@ -358,7 +358,7 @@ def open(
See more examples in the documentation of the ``read`` and ``write``
methods
"""
- self.mode = mode if mode else self.mode
+ self.mode = mode or self.mode
with_z = libvect.WITH_Z if with_z else libvect.WITHOUT_Z
# check if map exists or not
if not self.exist() and self.mode != "w":
@@ -396,8 +396,8 @@ def open(
# create a link
link = Link(
layer,
- link_name if link_name else self.name,
- tab_name if tab_name else self.name,
+ link_name or self.name,
+ tab_name or self.name,
link_key,
link_db,
link_driver,
diff --git a/python/grass/pygrass/vector/basic.py b/python/grass/pygrass/vector/basic.py
index 2b8c013b433..73eb5bb5557 100644
--- a/python/grass/pygrass/vector/basic.py
+++ b/python/grass/pygrass/vector/basic.py
@@ -133,9 +133,7 @@ def contains(self, point):
"""
return bool(
- libvect.Vect_point_in_box(
- point.x, point.y, point.z if point.z else 0, self.c_bbox
- )
+ libvect.Vect_point_in_box(point.x, point.y, point.z or 0, self.c_bbox)
)
def items(self):
@@ -424,7 +422,7 @@ def n_cats(self):
return self.c_cats.contents.n_cats
def __init__(self, c_cats=None):
- self.c_cats = c_cats if c_cats else ctypes.pointer(libvect.line_cats())
+ self.c_cats = c_cats or ctypes.pointer(libvect.line_cats())
def reset(self):
"""Reset the C cats struct from previous values."""
@@ -541,9 +539,7 @@ def max(self):
return [max_values[i] for i in range(self.n_ranges)]
def __init__(self, c_cat_list=None):
- self.c_cat_list = (
- c_cat_list if c_cat_list else ctypes.pointer(libvect.cat_list())
- )
+ self.c_cat_list = c_cat_list or ctypes.pointer(libvect.cat_list())
def from_string(self, string):
"""Converts string of categories and cat ranges separated by commas
diff --git a/python/grass/pygrass/vector/find.py b/python/grass/pygrass/vector/find.py
index 50599af5ab5..9333497f110 100644
--- a/python/grass/pygrass/vector/find.py
+++ b/python/grass/pygrass/vector/find.py
@@ -101,7 +101,7 @@ def node(self, point, maxdist):
self.c_mapinfo,
point.x,
point.y,
- point.z if point.z else 0,
+ point.z or 0,
float(maxdist),
int(not point.is2D),
)
@@ -166,7 +166,7 @@ def geo(self, point, maxdist, type="all", exclude=0):
self.c_mapinfo,
point.x,
point.y,
- point.z if point.z else 0,
+ point.z or 0,
self.vtype[type],
float(maxdist),
int(not point.is2D),
@@ -257,7 +257,7 @@ def geos(self, point, maxdist, type="all", exclude=None):
self.c_mapinfo,
point.x,
point.y,
- point.z if point.z else 0,
+ point.z or 0,
self.vtype[type],
float(maxdist),
int(not point.is2D),
@@ -586,7 +586,7 @@ def areas(self, bbox, boxlist=None, bboxlist_only=False):
>>> test_vect.close()
"""
- boxlist = boxlist if boxlist else BoxList()
+ boxlist = boxlist or BoxList()
if libvect.Vect_select_areas_by_box(
self.c_mapinfo, bbox.c_bbox, boxlist.c_boxlist
):
diff --git a/python/grass/pygrass/vector/geometry.py b/python/grass/pygrass/vector/geometry.py
index 8812ad77782..5b39d547bec 100644
--- a/python/grass/pygrass/vector/geometry.py
+++ b/python/grass/pygrass/vector/geometry.py
@@ -792,7 +792,7 @@ def bbox(self, bbox=None):
..
"""
- bbox = bbox if bbox else Bbox()
+ bbox = bbox or Bbox()
libvect.Vect_line_box(self.c_points, bbox.c_bbox)
return bbox
@@ -1376,7 +1376,7 @@ def __repr__(self):
def _centroid(self, side, idonly=False):
if side > 0:
v_id = libvect.Vect_get_area_centroid(self.c_mapinfo, side)
- v_id = v_id if v_id else None
+ v_id = v_id or None
if idonly:
return v_id
else:
@@ -1497,7 +1497,7 @@ def boundaries(self):
@mapinfo_must_be_set
def bbox(self, bbox=None):
"""Return bounding box of Isle"""
- bbox = bbox if bbox else Bbox()
+ bbox = bbox or Bbox()
libvect.Vect_get_isle_box(self.c_mapinfo, self.id, bbox.c_bbox)
return bbox
@@ -1700,7 +1700,7 @@ def bbox(self, bbox=None):
:param bbox: a Bbox object to fill with info from bounding box of area
:type bbox: a Bbox object
"""
- bbox = bbox if bbox else Bbox()
+ bbox = bbox or Bbox()
libvect.Vect_get_area_box(self.c_mapinfo, self.id, bbox.c_bbox)
return bbox
@@ -1798,7 +1798,7 @@ def cats(self, cats=None):
:param cats: a Cats object to fill with info with area categories
:type cats: a Cats object
"""
- cats = cats if cats else Cats()
+ cats = cats or Cats()
libvect.Vect_get_area_cats(self.c_mapinfo, self.id, cats.c_cats)
return cats
@@ -1820,7 +1820,7 @@ def contains_point(self, point, bbox=None):
:param bbox: the bounding box where run the analysis
:type bbox: a Bbox object
"""
- bbox = bbox if bbox else self.bbox()
+ bbox = bbox or self.bbox()
return bool(
libvect.Vect_point_in_area(
point.x, point.y, self.c_mapinfo, self.id, bbox.c_bbox
@@ -1897,8 +1897,8 @@ def read_next_line(
if c_cats is None:
free_cats = True
- c_points = c_points if c_points else ctypes.pointer(libvect.line_pnts())
- c_cats = c_cats if c_cats else ctypes.pointer(libvect.line_cats())
+ c_points = c_points or ctypes.pointer(libvect.line_pnts())
+ c_cats = c_cats or ctypes.pointer(libvect.line_cats())
ftype, v_id, c_points, c_cats = c_read_next_line(c_mapinfo, c_points, c_cats)
return GV_TYPE[ftype]["obj"](
v_id=v_id,
@@ -1945,8 +1945,8 @@ def read_line(
if c_cats is None:
free_cats = True
- c_points = c_points if c_points else ctypes.pointer(libvect.line_pnts())
- c_cats = c_cats if c_cats else ctypes.pointer(libvect.line_cats())
+ c_points = c_points or ctypes.pointer(libvect.line_pnts())
+ c_cats = c_cats or ctypes.pointer(libvect.line_cats())
feature_id, ftype, c_points, c_cats = c_read_line(
feature_id, c_mapinfo, c_points, c_cats
)
diff --git a/python/grass/pygrass/vector/table.py b/python/grass/pygrass/vector/table.py
index 3cca5689132..dec3ffbba08 100644
--- a/python/grass/pygrass/vector/table.py
+++ b/python/grass/pygrass/vector/table.py
@@ -1135,7 +1135,7 @@ def drop(self, cursor=None, force=False):
:type force: bool
"""
- cur = cursor if cursor else self.conn.cursor()
+ cur = cursor or self.conn.cursor()
if self.exist(cursor=cur):
used = db_table_in_vector(self.name)
if used is not None and len(used) > 0 and not force:
@@ -1194,8 +1194,8 @@ def execute(self, sql_code=None, cursor=None, many=False, values=None):
"""
try:
- sqlc = sql_code if sql_code else self.filters.get_sql()
- cur = cursor if cursor else self.conn.cursor()
+ sqlc = sql_code or self.filters.get_sql()
+ cur = cursor or self.conn.cursor()
if many and values:
return cur.executemany(sqlc, values)
return cur.execute(sqlc, values) if values else cur.execute(sqlc)
@@ -1212,7 +1212,7 @@ def exist(self, cursor=None):
:param cursor: the cursor to connect, if None it use the cursor
of connection table object
"""
- cur = cursor if cursor else self.conn.cursor()
+ cur = cursor or self.conn.cursor()
return table_exist(cur, self.name)
def insert(self, values, cursor=None, many=False):
@@ -1227,7 +1227,7 @@ def insert(self, values, cursor=None, many=False):
:param many: True to run executemany function
:type many: bool
"""
- cur = cursor if cursor else self.conn.cursor()
+ cur = cursor or self.conn.cursor()
if many:
return cur.executemany(self.columns.insert_str, values)
return cur.execute(self.columns.insert_str, values)
@@ -1246,7 +1246,7 @@ def update(self, key, values, cursor=None):
of connection table object
:type cursor: Cursor object
"""
- cur = cursor if cursor else self.conn.cursor()
+ cur = cursor or self.conn.cursor()
vals = list(values) + [
key,
]
@@ -1266,7 +1266,7 @@ def create(self, cols, name=None, overwrite=False, cursor=None):
:type cursor: Cursor object
"""
- cur = cursor if cursor else self.conn.cursor()
+ cur = cursor or self.conn.cursor()
coldef = ",\n".join(["%s %s" % col for col in cols])
if name:
newname = name
diff --git a/python/grass/script/tests/grass_script_core_location_test.py b/python/grass/script/tests/grass_script_core_location_test.py
index fdffa340b83..b389d41ba8d 100644
--- a/python/grass/script/tests/grass_script_core_location_test.py
+++ b/python/grass/script/tests/grass_script_core_location_test.py
@@ -167,7 +167,7 @@ def set_and_test_description(tmp_path, text):
gs.core._set_location_description(tmp_path, name, text)
description_file = tmp_path / name / "PERMANENT" / "MYNAME"
assert description_file.exists()
- text = text if text else "" # None and empty should both yield empty.
+ text = text or "" # None and empty should both yield empty.
assert description_file.read_text(encoding="utf-8").strip() == text
diff --git a/scripts/db.in.ogr/db.in.ogr.py b/scripts/db.in.ogr/db.in.ogr.py
index 0137a41d62c..a95919f4936 100755
--- a/scripts/db.in.ogr/db.in.ogr.py
+++ b/scripts/db.in.ogr/db.in.ogr.py
@@ -119,7 +119,7 @@ def main():
gs.fatal(_("Table <%s> already exists") % output)
# treat DB as real vector map...
- layer = db_table if db_table else None
+ layer = db_table or None
vopts = {}
if options["encoding"]:
diff --git a/scripts/g.extension/g.extension.py b/scripts/g.extension/g.extension.py
index 9ca0202a9fe..50e8a97d2bb 100644
--- a/scripts/g.extension/g.extension.py
+++ b/scripts/g.extension/g.extension.py
@@ -2595,7 +2595,7 @@ def resolve_known_host_service(url, name, branch):
if "branch" in match["url_end"]:
suffix = match["url_end"].format(
name=name,
- branch=branch if branch else get_default_branch(url),
+ branch=branch or get_default_branch(url),
)
else:
suffix = match["url_end"].format(name=name)
diff --git a/utils/mkhtml.py b/utils/mkhtml.py
index bc2c8d9b2de..69a1ba1db76 100644
--- a/utils/mkhtml.py
+++ b/utils/mkhtml.py
@@ -418,11 +418,8 @@ def get_last_git_commit(src_dir, addon_path, is_addon):
return get_git_commit_from_file(src_dir=src_dir)
-html_page_footer_pages_path = (
- os.getenv("HTML_PAGE_FOOTER_PAGES_PATH")
- if os.getenv("HTML_PAGE_FOOTER_PAGES_PATH")
- else ""
-)
+html_page_footer_pages_path = os.getenv("HTML_PAGE_FOOTER_PAGES_PATH") or ""
+
pgm = sys.argv[1]
src_file = "%s.html" % pgm
@@ -927,7 +924,7 @@ def to_title(name):
git_commit = get_last_git_commit(
src_dir=curdir,
- addon_path=addon_path if addon_path else None,
+ addon_path=addon_path or None,
is_addon=bool(addon_path),
)
if git_commit["commit"] == "unknown":