🎨 Sorted imports, made pylint happy

This commit is contained in:
GeoffreyCoulaud
2023-05-10 00:53:36 +02:00
parent c647ca1a31
commit 8a0951c727
4 changed files with 33 additions and 38 deletions

View File

@@ -18,18 +18,17 @@ from os import PathLike
from functools import wraps
def replaced_by_path(path: PathLike): # Decorator builder
def replaced_by_path(override: PathLike): # Decorator builder
"""Replace the method's returned path with the override
if the override exists on disk"""
def decorator(original_function): # Built decorator (closure)
@wraps(original_function)
def wrapper(*args, **kwargs): # func's override
p = Path(path).expanduser()
if p.exists():
return p
else:
return original_function(*args, **kwargs)
path = Path(override).expanduser()
if path.exists():
return path
return original_function(*args, **kwargs)
return wrapper
@@ -46,10 +45,9 @@ def replaced_by_schema_key(key: str): # Decorator builder
schema = args[0].win.schema
try:
override = schema.get_string(key)
except Exception:
except Exception: # pylint: disable=broad-exception-caught
return original_function(*args, **kwargs)
else:
return replaced_by_path(override)(original_function)(*args, **kwargs)
return replaced_by_path(override)(original_function)(*args, **kwargs)
return wrapper