diff --git a/nornir/core/filter.py b/nornir/core/filter.py index eb0db82a..e9d37b7e 100644 --- a/nornir/core/filter.py +++ b/nornir/core/filter.py @@ -90,12 +90,12 @@ def _verify_rules(data: Any, rule: List[str], value: Any) -> bool: if rule == ["any"]: if isinstance(data, list): - return any([x in data for x in value]) - return any([x == data for x in value]) + return any(x in data for x in value) + return any(x == data for x in value) if rule == ["all"]: if isinstance(data, list): - return all([x in data for x in value]) + return all(x in data for x in value) # it doesn't make sense to check a single value meets more than one case return False diff --git a/nornir/core/inventory.py b/nornir/core/inventory.py index f2615002..3768acda 100644 --- a/nornir/core/inventory.py +++ b/nornir/core/inventory.py @@ -95,9 +95,9 @@ def dict(self) -> Dict[str, Any]: class ParentGroups(List["Group"]): def __contains__(self, value: object) -> bool: if isinstance(value, str): - return any([value == g.name for g in self]) + return any(value == g.name for g in self) - return any([value == g for g in self]) + return any(value == g for g in self) def add(self, group: "Group") -> None: """ diff --git a/nornir/core/task.py b/nornir/core/task.py index b7bb2f1d..5c0660a7 100644 --- a/nornir/core/task.py +++ b/nornir/core/task.py @@ -258,12 +258,12 @@ def __repr__(self) -> str: @property def failed(self) -> bool: """If ``True`` at least a task failed.""" - return any([h.failed for h in self]) + return any(h.failed for h in self) @property def changed(self) -> bool: """If ``True`` at least a task changed the system.""" - return any([h.changed for h in self]) + return any(h.changed for h in self) def raise_on_error(self) -> None: """ @@ -290,7 +290,7 @@ def __repr__(self) -> str: @property def failed(self) -> bool: """If ``True`` at least a host failed.""" - return any([h.failed for h in self.values()]) + return any(h.failed for h in self.values()) @property def failed_hosts(self) -> Dict[str, "MultiResult"]: diff --git a/pyproject.toml b/pyproject.toml index a57b6014..fed67edf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -133,7 +133,6 @@ ignore = [ "ANN401", # Dynamically typed expressions (typing.Any) are disallowed "ARG002", # Unused method argument "B028", # No explicit `stacklevel` keyword argument found - "C419", # Unnecessary list comprehension "COM812", # Trailing comma missing "FBT001", # Boolean-typed positional argument in function definition "FBT002", # Boolean default positional argument in function definition