Skip to content

Commit a03fd75

Browse files
committed
Clean up lint
1 parent 4c3de5e commit a03fd75

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ unit-%:
5959
test:
6060
$(TOX) $(TOX_OPTS)
6161

62+
lint:
63+
python -m pre_commit run -a
64+
6265
bench:
6366
$(PYTHON) benchmark/benchmark.py
6467

@@ -70,7 +73,7 @@ analyze:
7073
types:
7174
mypy .
7275

73-
#
76+
#
7477
# Nix and VirtualEnv build, install and activate
7578
#
7679
# Create, start and run commands in "interactive" shell with a python venv's activate init-file.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,11 +1071,11 @@ the lines being wrapped would probably be significantly longer than this.
10711071

10721072
Text is preferably wrapped on whitespaces and right after the hyphens in hyphenated words.
10731073

1074-
break_long_words (default: True) If true, then words longer than width will be broken in order to ensure that no lines are longer than width.
1074+
break_long_words (default: True) If true, then words longer than width will be broken in order to ensure that no lines are longer than width.
10751075
If it is false, long words will not be broken, and some lines may be longer than width.
10761076
(Long words will be put on a line by themselves, in order to minimize the amount by which width is exceeded.)
10771077

1078-
break_on_hyphens (default: True) If true, wrapping will occur preferably on whitespaces and right after hyphens in compound words, as it is customary in English.
1078+
break_on_hyphens (default: True) If true, wrapping will occur preferably on whitespaces and right after hyphens in compound words, as it is customary in English.
10791079
If false, only whitespaces will be considered as potentially good places for line breaks.
10801080

10811081
```pycon

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
flake-utils.lib.eachDefaultSystem (system:
1111
let
1212
pkgs = nixpkgs.legacyPackages.${system};
13-
13+
1414
# Create Python environments with required packages
1515
mkPythonEnv = pythonPkg: pythonPkg.withPackages (ps: with ps; [
1616
pytest

tabulate/__init__.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,13 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):
16381638
return rows, headers, headers_pad
16391639

16401640

1641-
def _wrap_text_to_colwidths(list_of_lists, colwidths, numparses=True, break_long_words=_BREAK_LONG_WORDS, break_on_hyphens=_BREAK_ON_HYPHENS):
1641+
def _wrap_text_to_colwidths(
1642+
list_of_lists,
1643+
colwidths,
1644+
numparses=True,
1645+
break_long_words=_BREAK_LONG_WORDS,
1646+
break_on_hyphens=_BREAK_ON_HYPHENS,
1647+
):
16421648
if len(list_of_lists):
16431649
num_cols = len(list_of_lists[0])
16441650
else:
@@ -1655,7 +1661,11 @@ def _wrap_text_to_colwidths(list_of_lists, colwidths, numparses=True, break_long
16551661
continue
16561662

16571663
if width is not None:
1658-
wrapper = _CustomTextWrap(width=width, break_long_words=break_long_words, break_on_hyphens=break_on_hyphens)
1664+
wrapper = _CustomTextWrap(
1665+
width=width,
1666+
break_long_words=break_long_words,
1667+
break_on_hyphens=break_on_hyphens,
1668+
)
16591669
casted_cell = str(cell)
16601670
wrapped = [
16611671
"\n".join(wrapper.wrap(line))
@@ -2258,7 +2268,11 @@ def tabulate(
22582268

22592269
numparses = _expand_numparse(disable_numparse, num_cols)
22602270
list_of_lists = _wrap_text_to_colwidths(
2261-
list_of_lists, maxcolwidths, numparses=numparses, break_long_words=break_long_words, break_on_hyphens=break_on_hyphens
2271+
list_of_lists,
2272+
maxcolwidths,
2273+
numparses=numparses,
2274+
break_long_words=break_long_words,
2275+
break_on_hyphens=break_on_hyphens,
22622276
)
22632277

22642278
if maxheadercolwidths is not None:
@@ -2272,7 +2286,11 @@ def tabulate(
22722286

22732287
numparses = _expand_numparse(disable_numparse, num_cols)
22742288
headers = _wrap_text_to_colwidths(
2275-
[headers], maxheadercolwidths, numparses=numparses, break_long_words=break_long_words, break_on_hyphens=break_on_hyphens
2289+
[headers],
2290+
maxheadercolwidths,
2291+
numparses=numparses,
2292+
break_long_words=break_long_words,
2293+
break_on_hyphens=break_on_hyphens,
22762294
)[0]
22772295

22782296
# empty values in the first column of RST tables should be escaped (issue #82)
@@ -2742,7 +2760,7 @@ def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
27422760
# Reverted the broken ANSI code handling stuff to fix wcwidth handling
27432761
# - Doesn't use self._lend, infinite loops
27442762
# - doesn't locate chunks correctly b/c could be split by ANSI codes
2745-
#
2763+
#
27462764
# if self.break_long_words and space_left > 0:
27472765
# # Tabulate Custom: Build the string up piece-by-piece in order to
27482766
# # take each charcter's width into account
@@ -2768,7 +2786,7 @@ def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
27682786
# cur_line.append(chunk[: i + total_escape_len - 1])
27692787
# reversed_chunks[-1] = chunk[i + total_escape_len - 1 :]
27702788

2771-
if self.break_long_words: # and space_left > 0:
2789+
if self.break_long_words: # and space_left > 0:
27722790
# Tabulate Custom: Build the string up piece-by-piece in order to
27732791
# take each charcter's width into account
27742792
chunk = reversed_chunks[-1]

test/test_output.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,6 +3320,7 @@ def test_preserve_whitespace():
33203320
result = tabulate(test_table, table_headers, preserve_whitespace=False)
33213321
assert_equal(expected, result)
33223322

3323+
33233324
def test_break_long_words():
33243325
"Output: Default table output, with breakwords true."
33253326
table_headers = ["h1", "h2", "h3"]
@@ -3335,6 +3336,7 @@ def test_break_long_words():
33353336
result = tabulate(test_table, table_headers, maxcolwidths=3, break_long_words=True)
33363337
assert_equal(expected, result)
33373338

3339+
33383340
def test_break_on_hyphens():
33393341
"Output: Default table output, with break on hyphens true."
33403342
table_headers = ["h1", "h2", "h3"]

0 commit comments

Comments
 (0)