Skip to content

Commit cc70092

Browse files
committed
refactor: use list comprehension rather filter+lambda
1 parent 6fd2ad2 commit cc70092

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

repo2docker/buildpacks/base.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,18 @@ def _filter_tar(tarinfo):
612612

613613
exclude = []
614614

615-
for ignore_file in [".dockerignore", ".containerignore"]:
616-
if os.path.exists(ignore_file):
617-
with open(ignore_file, "r") as f:
615+
for ignore_file_name in [".dockerignore", ".containerignore"]:
616+
if os.path.exists(ignore_file_name):
617+
with open(ignore_file_name, "r") as ignore_file:
618+
cleaned_lines = [
619+
line.strip() for line in ignore_file.read().splitlines()
620+
]
618621
exclude.extend(
619-
list(
620-
filter(
621-
lambda x: x != "" and x[0] != "#",
622-
[l.strip() for l in f.read().splitlines()],
623-
)
624-
)
622+
[
623+
line
624+
for line in cleaned_lines
625+
if line != "" and line[0] != "#"
626+
]
625627
)
626628

627629
if not exclude:

0 commit comments

Comments
 (0)