Skip to content

Commit 39d77f2

Browse files
committed
Add flake8-comprehensions
./testinfra/backend/salt.py:55:12: C407 Unnecessary list comprehension - 'any' can take a generator. ./testinfra/utils/ansible_runner.py:226:29: C414 Unnecessary list call within sorted(). ./testinfra/modules/addr.py:97:21: C401 Unnecessary generator - rewrite as a set comprehension.
1 parent 5e6cae0 commit 39d77f2

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

testinfra/backend/salt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def run_salt(self, func, args=None):
5252
def get_hosts(cls, host, **kwargs):
5353
if host is None:
5454
host = "*"
55-
if any([c in host for c in "@*[?"]):
55+
if any(c in host for c in "@*[?"):
5656
client = salt.client.LocalClient()
5757
if "@" in host:
5858
hosts = client.cmd(

testinfra/modules/addr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ def _resolve(self, method):
137137
result = self.run_expect([0, 1, 2], "{}getent {} {}".format(
138138
self._prefix, method, self.name))
139139
lines = result.stdout.splitlines()
140-
return list(set(line.split()[0] for line in lines))
140+
return list({line.split()[0] for line in lines})

testinfra/utils/ansible_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def get_variables(self, host):
223223
for group in sorted(inventory):
224224
if group == "_meta":
225225
continue
226-
groups[group] = sorted(list(itergroup(inventory, group)))
226+
groups[group] = sorted(itergroup(inventory, group))
227227
if group != "all" and host in inventory[group].get('hosts', []):
228228
group_names.append(group)
229229
hostvars.setdefault('group_names', group_names)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ deps=
2020
flake8
2121
hacking
2222
flake8-bugbear
23+
flake8-comprehensions
2324
commands=flake8 {posargs}
2425

2526
[testenv:docs]

0 commit comments

Comments
 (0)