From f78d04fcfc474c916feec93f2c352ae29e493d88 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 15 Mar 2022 09:23:48 +0000 Subject: [PATCH] Address pylint dangerous-default-value (#2008) --- .pylintrc | 1 - src/ansiblelint/rules/__init__.py | 9 ++++++++- src/ansiblelint/runner.py | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.pylintrc b/.pylintrc index a383e4bc5b..47b7c04627 100644 --- a/.pylintrc +++ b/.pylintrc @@ -17,7 +17,6 @@ disable = line-too-long, # TODO(ssbarnea): remove temporary skips adding during initial adoption: consider-using-f-string, - dangerous-default-value, duplicate-code, [TYPECHECK] diff --git a/src/ansiblelint/rules/__init__.py b/src/ansiblelint/rules/__init__.py index 8b51d04bc8..4d6c80848d 100644 --- a/src/ansiblelint/rules/__init__.py +++ b/src/ansiblelint/rules/__init__.py @@ -270,10 +270,17 @@ def extend(self, more: List[AnsibleLintRule]) -> None: self.rules.extend(more) def run( - self, file: Lintable, tags: Set[str] = set(), skip_list: List[str] = [] + self, + file: Lintable, + tags: Optional[Set[str]] = None, + skip_list: Optional[List[str]] = None, ) -> List[MatchError]: """Run all the rules against the given lintable.""" matches: List[MatchError] = [] + if tags is None: + tags = set() + if skip_list is None: + skip_list = [] if not file.path.is_dir(): try: diff --git a/src/ansiblelint/runner.py b/src/ansiblelint/runner.py index dcd441d9fd..531504fcb6 100644 --- a/src/ansiblelint/runner.py +++ b/src/ansiblelint/runner.py @@ -40,8 +40,8 @@ def __init__( *lintables: Union[Lintable, str], rules: "RulesCollection", tags: FrozenSet[Any] = frozenset(), - skip_list: List[str] = [], - exclude_paths: List[str] = [], + skip_list: Optional[List[str]] = None, + exclude_paths: Optional[List[str]] = None, verbosity: int = 0, checked_files: Optional[Set[Lintable]] = None ) -> None: @@ -49,6 +49,11 @@ def __init__( self.rules = rules self.lintables: Set[Lintable] = set() + if skip_list is None: + skip_list = [] + if exclude_paths is None: + exclude_paths = [] + # Assure consistent type for item in lintables: if not isinstance(item, Lintable):