Don't use mutable default arguments to functions
This commit is contained in:
@@ -47,7 +47,7 @@ class IResolver:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def build_search_paths(cls, config: Config, user_subdir: Optional[str] = None,
|
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] = []
|
abs_paths: List[Path] = []
|
||||||
if cls.initial_search_path:
|
if cls.initial_search_path:
|
||||||
@@ -57,8 +57,9 @@ class IResolver:
|
|||||||
abs_paths.insert(0, config['user_data_dir'].joinpath(user_subdir))
|
abs_paths.insert(0, config['user_data_dir'].joinpath(user_subdir))
|
||||||
|
|
||||||
# Add extra directory to the top of the search paths
|
# Add extra directory to the top of the search paths
|
||||||
for dir in extra_dirs:
|
if extra_dirs:
|
||||||
abs_paths.insert(0, Path(dir).resolve())
|
for dir in extra_dirs:
|
||||||
|
abs_paths.insert(0, Path(dir).resolve())
|
||||||
|
|
||||||
if cls.extra_path and (extra := config.get(cls.extra_path)):
|
if cls.extra_path and (extra := config.get(cls.extra_path)):
|
||||||
abs_paths.insert(0, Path(extra).resolve())
|
abs_paths.insert(0, Path(extra).resolve())
|
||||||
@@ -139,7 +140,7 @@ class IResolver:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _load_object(cls, paths: List[Path], *, object_name: str, add_source: bool = False,
|
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.
|
Try to load object from path list.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user