Don't use mutable default arguments to functions

This commit is contained in:
Matthias
2024-04-20 09:09:42 +02:00
parent 9b1def604f
commit 448b74840e

View File

@@ -47,7 +47,7 @@ class IResolver:
@classmethod
def build_search_paths(cls, config: Config, user_subdir: Optional[str] = None,
extra_dirs: List[str] = []) -> List[Path]:
extra_dirs: Optional[List[str]] = None) -> List[Path]:
abs_paths: List[Path] = []
if cls.initial_search_path:
@@ -57,8 +57,9 @@ class IResolver:
abs_paths.insert(0, config['user_data_dir'].joinpath(user_subdir))
# Add extra directory to the top of the search paths
for dir in extra_dirs:
abs_paths.insert(0, Path(dir).resolve())
if extra_dirs:
for dir in extra_dirs:
abs_paths.insert(0, Path(dir).resolve())
if cls.extra_path and (extra := config.get(cls.extra_path)):
abs_paths.insert(0, Path(extra).resolve())
@@ -139,7 +140,7 @@ class IResolver:
@classmethod
def _load_object(cls, paths: List[Path], *, object_name: str, add_source: bool = False,
kwargs: dict = {}) -> Optional[Any]:
kwargs: Dict) -> Optional[Any]:
"""
Try to load object from path list.
"""