simplify if statements by using walrus operators (#7671)

This commit is contained in:
Mike Fährmann
2025-07-22 18:34:38 +02:00
parent e8b2a496ba
commit a097a373a9
83 changed files with 239 additions and 466 deletions

View File

@@ -235,8 +235,7 @@ modules = [
def find(url):
"""Find a suitable extractor for the given URL"""
for cls in _list_classes():
match = cls.pattern.match(url)
if match:
if match := cls.pattern.match(url):
return cls(match)
return None
@@ -251,8 +250,7 @@ def add(cls):
def add_module(module):
"""Add all extractors in 'module' to the list of available extractors"""
classes = _get_classes(module)
if classes:
if classes := _get_classes(module):
if isinstance(classes[0].pattern, str):
for cls in classes:
cls.pattern = re_compile(cls.pattern)