Skip to content

Commit ec4ff6d

Browse files
committed
Use list comprehensions
1 parent 4e8a70e commit ec4ff6d

3 files changed

Lines changed: 3 additions & 12 deletions

File tree

rpmlint/checks/AbstractCheck.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def check_binary(self, pkg):
5050
# start with the biggest files first
5151
filenames = sorted(filenames, key=lambda x: pkg.files[x].size, reverse=True)
5252
with concurrent.futures.ThreadPoolExecutor() as executor:
53-
futures = []
54-
for filename in filenames:
55-
futures.append(executor.submit(self.check_file, pkg, filename))
53+
futures = [executor.submit(self.check_file, pkg, filename) for filename in filenames]
5654
concurrent.futures.wait(futures)
5755
for future in futures:
5856
err = future.exception()

rpmlint/pkg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,18 +745,14 @@ def get_core_reqs(self):
745745
def get_installed_pkgs(name):
746746
"""Get list of installed package objects by name."""
747747

748-
pkgs = []
749748
ts = rpm.TransactionSet()
750749
if re.search(r'[?*]|\[.+\]', name):
751750
mi = ts.dbMatch()
752751
mi.pattern('name', rpm.RPMMIRE_GLOB, name)
753752
else:
754753
mi = ts.dbMatch('name', name)
755754

756-
for hdr in mi:
757-
pkgs.append(InstalledPkg(name, hdr))
758-
759-
return pkgs
755+
return [InstalledPkg(name, hdr) for hdr in mi]
760756

761757

762758
# Class to provide an API to an installed package

test/test_lint.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,7 @@ def test_run_full_specs(capsys, packages, configs):
385385
@pytest.mark.no_cover
386386
def test_run_full_directory(capsys, packages):
387387
assert packages.is_dir()
388-
file_list = []
389-
for item in packages.iterdir():
390-
if item.is_file():
391-
file_list.append(item)
388+
file_list = [item for item in packages.iterdir() if item.is_file()]
392389
number_of_pkgs = len(file_list)
393390
additional_options = {
394391
'rpmfile': [packages],

0 commit comments

Comments
 (0)