diff --git a/pywikibot/diff.py b/pywikibot/diff.py index 005da215d5..d1ec07c8c0 100644 --- a/pywikibot/diff.py +++ b/pywikibot/diff.py @@ -139,7 +139,7 @@ def format_diff(self) -> Iterable[str]: # or color whole line to be added. fmt = fmt if fmt.startswith('?') else '' fmt = fmt[:min(len(fmt), len(line1))] - fmt = fmt if fmt else None + fmt = fmt or None yield self.color_line(line1, fmt) # handle last line @@ -155,7 +155,7 @@ def format_diff(self) -> Iterable[str]: # or color whole line to be added. fmt = line1 if line1.startswith('?') else '' fmt = fmt[:min(len(fmt), len(line2))] - fmt = fmt if fmt else None + fmt = fmt or None yield self.color_line(line2, fmt) def color_line(self, line: str, line_ref: str | None = None) -> str: diff --git a/pywikibot/site/_datasite.py b/pywikibot/site/_datasite.py index fd27d56dd7..e96d49478c 100644 --- a/pywikibot/site/_datasite.py +++ b/pywikibot/site/_datasite.py @@ -188,7 +188,7 @@ def loadcontent(self, identification, *props): # TODO: When props is empty it results in # an empty string ('&props=') but it should # result in a missing entry. - props=props if props else False) + props=props or False) req = self.simple_request(**params) data = req.submit() if 'success' not in data: diff --git a/scripts/category.py b/scripts/category.py index 12ac25e042..15200be104 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -710,7 +710,7 @@ def __init__(self, oldcat, # Category is deleted. self.deletion_comment = i18n.twtranslate( self.site, 'category-was-disbanded') - self.move_comment = move_comment if move_comment else self.comment + self.move_comment = move_comment or self.comment def run(self) -> None: """The main bot function that does all the work.