Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address pylint dangerous-default-value #2008

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 8 additions & 1 deletion src/ansiblelint/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions src/ansiblelint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ 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:
"""Initialize a Runner instance."""
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):
Expand Down