simplify if statements by using walrus operators (#7671)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user