Skip to content

Commit

Permalink
Apply ruff/flake8-comprehensions rule C417
Browse files Browse the repository at this point in the history
C417 Unnecessary `map` usage (rewrite using a generator expression)
  • Loading branch information
DimitriPapadopoulos committed Sep 27, 2024
1 parent 685460b commit 7c1a3e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion benchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def benchmark(n):
results = [
(desc, timeit(code, setup_code, number=n) / n * 1e6) for desc, code in methods
]
mintime = min(map(lambda x: x[1], results))
mintime = min((x[1] for x in results))
results = [
(desc, t, t / mintime) for desc, t in sorted(results, key=lambda x: x[1])
]
Expand Down
2 changes: 1 addition & 1 deletion tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):

headers = list(map(str, headers))
# rows = list(map(list, rows))
rows = list(map(lambda r: r if _is_separating_line(r) else list(r), rows))
rows = [r if _is_separating_line(r) else list(r) for r in rows]

# add or remove an index column
showindex_is_a_str = type(showindex) in [str, bytes]
Expand Down
6 changes: 3 additions & 3 deletions test/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def test_iterable_of_iterables():
"Input: an iterable of iterables."
ii = iter(map(lambda x: iter(x), [range(5), range(5, 0, -1)]))
ii = iter((iter(x) for x in [range(5), range(5, 0, -1)]))
expected = "\n".join(
["- - - - -", "0 1 2 3 4", "5 4 3 2 1", "- - - - -"]
)
Expand All @@ -22,7 +22,7 @@ def test_iterable_of_iterables():

def test_iterable_of_iterables_headers():
"Input: an iterable of iterables with headers."
ii = iter(map(lambda x: iter(x), [range(5), range(5, 0, -1)]))
ii = iter((iter(x) for x in [range(5), range(5, 0, -1)]))
expected = "\n".join(
[
" a b c d e",
Expand All @@ -37,7 +37,7 @@ def test_iterable_of_iterables_headers():

def test_iterable_of_iterables_firstrow():
"Input: an iterable of iterables with the first row as headers"
ii = iter(map(lambda x: iter(x), ["abcde", range(5), range(5, 0, -1)]))
ii = iter((iter(x) for x in ["abcde", range(5), range(5, 0, -1)]))
expected = "\n".join(
[
" a b c d e",
Expand Down

0 comments on commit 7c1a3e5

Please sign in to comment.