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):