Skip to content

Commit

Permalink
Apply ruff rule RUF100
Browse files Browse the repository at this point in the history
RUF100 Unused blanket `noqa` directive
  • Loading branch information
DimitriPapadopoulos committed Oct 1, 2024
1 parent 8c9cffc commit 198b84d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
10 changes: 5 additions & 5 deletions tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _is_file(f):

__all__ = ["simple_separated_format", "tabulate", "tabulate_formats"]
try:
from .version import version as __version__ # noqa: F401
from .version import version as __version__
except ImportError:
pass # running __init__.py as a script, AppVeyor pytests

Expand Down Expand Up @@ -1090,7 +1090,7 @@ def _choose_width_fn(has_invisible, enable_widechars, is_multiline):
else:
line_width_fn = len
if is_multiline:
width_fn = lambda s: _multiline_width(s, line_width_fn) # noqa
width_fn = lambda s: _multiline_width(s, line_width_fn)
else:
width_fn = line_width_fn
return width_fn
Expand Down Expand Up @@ -1130,7 +1130,7 @@ def _align_column_choose_width_fn(has_invisible, enable_widechars, is_multiline)
else:
line_width_fn = len
if is_multiline:
width_fn = lambda s: _align_column_multiline_width(s, line_width_fn) # noqa
width_fn = lambda s: _align_column_multiline_width(s, line_width_fn)
else:
width_fn = line_width_fn
return width_fn
Expand Down Expand Up @@ -1261,7 +1261,7 @@ def _format(val, valtype, floatfmt, intfmt, missingval="", has_invisible=True):
tabulate(tbl, headers=hrow) == good_result
True
""" # noqa
"""
if val is None:
return missingval

Expand Down Expand Up @@ -2542,7 +2542,7 @@ def _format_table(

padded_widths = [(w + 2 * pad) for w in colwidths]
if is_multiline:
pad_row = lambda row, _: row # noqa do it later, in _append_multiline_row
pad_row = lambda row, _: row
append_row = partial(_append_multiline_row, pad=pad)
else:
pad_row = _pad_row
Expand Down
4 changes: 2 additions & 2 deletions test/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest # noqa
from pytest import skip, raises # noqa
import pytest
from pytest import skip, raises
import warnings


Expand Down
6 changes: 3 additions & 3 deletions test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_tabulate_formats():
print("tabulate_formats = %r" % supported)
assert type(supported) is list
for fmt in supported:
assert type(fmt) is str # noqa
assert type(fmt) is str


def _check_signature(function, expected_sig):
Expand All @@ -36,7 +36,7 @@ def _check_signature(function, expected_sig):

def test_tabulate_signature():
"API: tabulate() type signature is unchanged" ""
assert type(tabulate) is type(lambda: None) # noqa
assert type(tabulate) is type(lambda: None)
expected_sig = [
("tabular_data", _empty),
("headers", ()),
Expand All @@ -62,6 +62,6 @@ def test_tabulate_signature():

def test_simple_separated_format_signature():
"API: simple_separated_format() type signature is unchanged" ""
assert type(simple_separated_format) is type(lambda: None) # noqa
assert type(simple_separated_format) is type(lambda: None)
expected_sig = [("separator", _empty)]
_check_signature(simple_separated_format, expected_sig)
4 changes: 2 additions & 2 deletions test/test_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_wrap_text_to_colwidths():
def test_wrap_text_wide_chars():
"Internal: Wrap wide characters based on column width"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_wrap_text_wide_chars is skipped")

Expand Down Expand Up @@ -242,7 +242,7 @@ def test_wrap_text_to_colwidths_single_ansi_colors_full_cell():
def test_wrap_text_to_colwidths_colors_wide_char():
"""Internal: autowrapped text can retain a ANSI colors with wide chars"""
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_wrap_text_to_colwidths_colors_wide_char is skipped")

Expand Down
36 changes: 18 additions & 18 deletions test/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_plain_maxcolwidth_autowraps_with_sep():
def test_plain_maxcolwidth_autowraps_wide_chars():
"Output: maxcolwidth and autowrapping functions with wide characters"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_wrap_text_wide_chars is skipped")

Expand Down Expand Up @@ -492,7 +492,7 @@ def test_grid():
def test_grid_wide_characters():
"Output: grid with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -627,7 +627,7 @@ def test_simple_grid():
def test_simple_grid_wide_characters():
"Output: simple_grid with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_simple_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -762,7 +762,7 @@ def test_rounded_grid():
def test_rounded_grid_wide_characters():
"Output: rounded_grid with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_rounded_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -897,7 +897,7 @@ def test_heavy_grid():
def test_heavy_grid_wide_characters():
"Output: heavy_grid with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_heavy_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1032,7 +1032,7 @@ def test_mixed_grid():
def test_mixed_grid_wide_characters():
"Output: mixed_grid with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_mixed_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1167,7 +1167,7 @@ def test_double_grid():
def test_double_grid_wide_characters():
"Output: double_grid with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_double_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def test_fancy_grid():
def test_fancy_grid_wide_characters():
"Output: fancy_grid with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_fancy_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1471,7 +1471,7 @@ def test_colon_grid():
def test_colon_grid_wide_characters():
"Output: colon_grid with wide chars in header"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_colon_grid_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1565,7 +1565,7 @@ def test_outline():
def test_outline_wide_characters():
"Output: outline with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_outline_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1617,7 +1617,7 @@ def test_simple_outline():
def test_simple_outline_wide_characters():
"Output: simple_outline with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_simple_outline_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1669,7 +1669,7 @@ def test_rounded_outline():
def test_rounded_outline_wide_characters():
"Output: rounded_outline with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_rounded_outline_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1721,7 +1721,7 @@ def test_heavy_outline():
def test_heavy_outline_wide_characters():
"Output: heavy_outline with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_heavy_outline_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1773,7 +1773,7 @@ def test_mixed_outline():
def test_mixed_outline_wide_characters():
"Output: mixed_outline with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_mixed_outline_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1825,7 +1825,7 @@ def test_double_outline():
def test_double_outline_wide_characters():
"Output: double_outline with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_double_outline_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -1877,7 +1877,7 @@ def test_fancy_outline():
def test_fancy_outline_wide_characters():
"Output: fancy_outline with wide characters in headers"
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_fancy_outline_wide_characters is skipped")
headers = list(_test_table_headers)
Expand Down Expand Up @@ -2536,7 +2536,7 @@ def test_html():
[
"<table>",
"<thead>",
'<tr><th>&lt;strings&gt; </th><th style="text-align: right;"> &lt;&amp;numbers&amp;&gt;</th></tr>', # noqa
'<tr><th>&lt;strings&gt; </th><th style="text-align: right;"> &lt;&amp;numbers&amp;&gt;</th></tr>',
"</thead>",
"<tbody>",
'<tr><td>spam &gt; </td><td style="text-align: right;"> 41.9999</td></tr>',
Expand All @@ -2557,7 +2557,7 @@ def test_unsafehtml():
[
"<table>",
"<thead>",
"<tr><th>strings </th><th>numbers </th></tr>", # noqa
"<tr><th>strings </th><th>numbers </th></tr>",
"</thead>",
"<tbody>",
'<tr><td>spam </td><td><font color="red">41.9999</font></td></tr>',
Expand Down
4 changes: 2 additions & 2 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class textclass(str):
def test_mix_normal_and_wide_characters():
"Regression: wide characters in a grid format (issue #51)"
try:
import wcwidth # noqa
import wcwidth

ru_text = "\u043f\u0440\u0438\u0432\u0435\u0442"
cn_text = "\u4f60\u597d"
Expand All @@ -322,7 +322,7 @@ def test_mix_normal_and_wide_characters():
def test_multiline_with_wide_characters():
"Regression: multiline tables with varying number of wide characters (github issue #28)"
try:
import wcwidth # noqa
import wcwidth

table = [["가나\n가ab", "가나", "가나"]]
result = tabulate(table, tablefmt="fancy_grid")
Expand Down
6 changes: 3 additions & 3 deletions test/test_textwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_wrap_longword_non_wide():
def test_wrap_wide_char_multiword():
"""TextWrapper: wrapping support for wide characters with multiple words"""
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_wrap_wide_char is skipped")

Expand All @@ -63,7 +63,7 @@ def test_wrap_wide_char_multiword():
def test_wrap_wide_char_longword():
"""TextWrapper: wrapping wide char word that needs to be broken up"""
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_wrap_wide_char_longword is skipped")

Expand All @@ -80,7 +80,7 @@ def test_wrap_wide_char_longword():
def test_wrap_mixed_string():
"""TextWrapper: wrapping string with mix of wide and non-wide chars"""
try:
import wcwidth # noqa
import wcwidth
except ImportError:
skip("test_wrap_wide_char is skipped")

Expand Down

0 comments on commit 198b84d

Please sign in to comment.