Skip to content

Commit cf45298

Browse files
committed
apply black to fix linting errors
1 parent ae3d485 commit cf45298

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

HOWTOPUBLISH

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ tox -e py39-extra,py310-extra,py311-extra,py312-extra,py313-extra
44
# tag version release
55
python -m build -s # this will update tabulate/version.py
66
python -m pip install . # install tabulate in the current venv
7-
python -m pip install -r benchmark/requirements.txt
7+
python -m pip install -r benchmark/requirements.txt
88
python benchmark/benchmark.py # then update README
99
# move tag to the last commit
1010
python -m build -s # update tabulate/version.py
1111
python -m build -nswx .
12-
git push # wait for all CI builds to succeed
12+
git push # wait for all CI builds to succeed
1313
git push --tags # if CI builds succeed
1414
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
1515
twine upload dist/*

tabulate/__init__.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,17 @@ def _type(string, has_invisible=True, numparse=True):
961961
elif _isbool(string):
962962
return bool
963963
elif numparse and (
964-
_isint(string) or (
964+
_isint(string)
965+
or (
965966
isinstance(string, str)
966967
and _isnumber_with_thousands_separator(string)
967-
and '.' not in string
968+
and "." not in string
968969
)
969970
):
970971
return int
971972
elif numparse and (
972-
_isnumber(string) or (
973-
isinstance(string, str)
974-
and _isnumber_with_thousands_separator(string)
975-
)
973+
_isnumber(string)
974+
or (isinstance(string, str) and _isnumber_with_thousands_separator(string))
976975
):
977976
return float
978977
elif isinstance(string, bytes):
@@ -1316,8 +1315,8 @@ def _format(val, valtype, floatfmt, intfmt, missingval="", has_invisible=True):
13161315
formatted_val = format(float(raw_val), floatfmt)
13171316
return val.replace(raw_val, formatted_val)
13181317
else:
1319-
if isinstance(val,str) and ',' in val:
1320-
val = val.replace(',', '') # handle thousands-separators
1318+
if isinstance(val, str) and "," in val:
1319+
val = val.replace(",", "") # handle thousands-separators
13211320
return format(float(val), floatfmt)
13221321
else:
13231322
return f"{val}"
@@ -2584,7 +2583,12 @@ def _format_table(
25842583
for row, ralign in zip(rows[:-1], rowaligns):
25852584
if row != SEPARATING_LINE:
25862585
append_row(
2587-
lines, pad_row(row, pad), padded_widths, colaligns, fmt.datarow, rowalign=ralign
2586+
lines,
2587+
pad_row(row, pad),
2588+
padded_widths,
2589+
colaligns,
2590+
fmt.datarow,
2591+
rowalign=ralign,
25882592
)
25892593
_append_line(lines, padded_widths, colaligns, fmt.linebetweenrows)
25902594
# the last row without a line below
@@ -2610,7 +2614,9 @@ def _format_table(
26102614
if _is_separating_line(row):
26112615
_append_line(lines, padded_widths, colaligns, separating_line)
26122616
else:
2613-
append_row(lines, pad_row(row, pad), padded_widths, colaligns, fmt.datarow)
2617+
append_row(
2618+
lines, pad_row(row, pad), padded_widths, colaligns, fmt.datarow
2619+
)
26142620

26152621
if fmt.linebelow and "linebelow" not in hidden:
26162622
_append_line(lines, padded_widths, colaligns, fmt.linebelow)
@@ -2705,11 +2711,14 @@ def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
27052711
if _ansi_codes.search(chunk) is not None:
27062712
for group, _, _, _ in _ansi_codes.findall(chunk):
27072713
escape_len = len(group)
2708-
if group in chunk[last_group: i + total_escape_len + escape_len - 1]:
2714+
if (
2715+
group
2716+
in chunk[last_group : i + total_escape_len + escape_len - 1]
2717+
):
27092718
total_escape_len += escape_len
27102719
found = _ansi_codes.search(chunk[last_group:])
27112720
last_group += found.end()
2712-
cur_line.append(chunk[: i + total_escape_len - 1])
2721+
cur_line.append(chunk[: i + total_escape_len - 1])
27132722
reversed_chunks[-1] = chunk[i + total_escape_len - 1 :]
27142723

27152724
# Otherwise, we have to preserve the long word intact. Only add

test/test_internal.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ def test_wrap_text_wide_chars():
180180
except ImportError:
181181
skip("test_wrap_text_wide_chars is skipped")
182182

183-
rows = [
184-
["청자청자청자청자청자", "약간 감싸면 더 잘 보일 수있는 다소 긴 설명입니다"]
185-
]
183+
rows = [["청자청자청자청자청자", "약간 감싸면 더 잘 보일 수있는 다소 긴 설명입니다"]]
186184
widths = [5, 20]
187185
expected = [
188186
[
@@ -246,14 +244,7 @@ def test_wrap_text_to_colwidths_colors_wide_char():
246244
except ImportError:
247245
skip("test_wrap_text_to_colwidths_colors_wide_char is skipped")
248246

249-
data = [
250-
[
251-
(
252-
"\033[31m약간 감싸면 더 잘 보일 수있는 다소 긴"
253-
" 설명입니다 설명입니다 설명입니다 설명입니다 설명\033[0m"
254-
)
255-
]
256-
]
247+
data = [[("\033[31m약간 감싸면 더 잘 보일 수있는 다소 긴" " 설명입니다 설명입니다 설명입니다 설명입니다 설명\033[0m")]]
257248
result = T._wrap_text_to_colwidths(data, [30])
258249

259250
expected = [

test/test_output.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2863,7 +2863,9 @@ def test_floatfmt():
28632863

28642864
def test_floatfmt_thousands():
28652865
"Output: floating point format"
2866-
result = tabulate([["1.23456789"], [1.0], ["1,234.56"]], floatfmt=".3f", tablefmt="plain")
2866+
result = tabulate(
2867+
[["1.23456789"], [1.0], ["1,234.56"]], floatfmt=".3f", tablefmt="plain"
2868+
)
28672869
expected = " 1.235\n 1.000\n1234.560"
28682870
assert_equal(expected, result)
28692871

0 commit comments

Comments
 (0)