Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions benchmark/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import sys
from timeit import timeit
import tabulate

import prettytable
import texttable
import sys

import tabulate

setup_code = r"""
from csv import writer
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ dev = [
line-length = 99

[tool.ruff.lint]
extend-select = ["W", "C90"]
extend-select = ["W", "I", "C90"]
ignore = ["E721", "C901"]

[tool.ruff.lint.mccabe]
max-complexity = 22

[tool.ruff.lint.isort]
combine-as-imports = true
force-sort-within-sections = true
known-local-folder = ["common"]
14 changes: 7 additions & 7 deletions tabulate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
"""Pretty-print tabular data."""

from importlib.metadata import (
version as _version,
PackageNotFoundError as _PackageNotFoundError,
version as _version,
)

try:
__version__ = _version("tabulate")
except _PackageNotFoundError:
__version__ = "unknown"

import warnings
from collections import namedtuple
from collections.abc import Iterable, Sized
import dataclasses
from decimal import Decimal
from functools import partial, reduce
from html import escape as htmlescape
from itertools import chain, zip_longest as izip_longest
from functools import reduce, partial
import io
import re
from itertools import chain, zip_longest as izip_longest
import math
import textwrap
import dataclasses
import re
import sys
import textwrap
import warnings

try:
import wcwidth # optional wide-character (CJK) support
Expand Down
5 changes: 3 additions & 2 deletions test/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pytest # noqa: F401
from pytest import skip, raises # noqa: F401
import warnings

import pytest # noqa: F401
from pytest import raises, skip # noqa: F401


def assert_equal(expected, result):
print("Expected:\n%r\n" % expected)
Expand Down
6 changes: 3 additions & 3 deletions test/test_api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""API properties."""

from tabulate import tabulate, tabulate_formats, simple_separated_format
from common import skip
from tabulate import simple_separated_format, tabulate, tabulate_formats

from common import skip

try:
from inspect import signature, _empty
from inspect import _empty, signature
except ImportError:
signature = None
_empty = None
Expand Down
6 changes: 1 addition & 5 deletions test/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
"""Command-line interface."""

import os
import sys


import subprocess
import sys
import tempfile


from common import assert_equal


SAMPLE_SIMPLE_FORMAT = "\n".join(
[
"----- ------ -------------",
Expand Down
3 changes: 2 additions & 1 deletion test/test_input.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test support of the various forms of tabular data."""

from tabulate import tabulate, SEPARATING_LINE
from tabulate import SEPARATING_LINE, tabulate

from common import assert_equal, assert_in, raises, skip

try:
Expand Down
2 changes: 1 addition & 1 deletion test/test_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import tabulate as T

from common import assert_equal, skip, rows_to_pipe_table_str, cols_to_pipe_str
from common import assert_equal, cols_to_pipe_str, rows_to_pipe_table_str, skip


def test_multiline_width():
Expand Down
6 changes: 4 additions & 2 deletions test/test_output.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""Test output of the various forms of tabular data."""

from decimal import Decimal

from pytest import mark

from common import assert_equal, raises, skip, check_warnings
from tabulate import tabulate, simple_separated_format, SEPARATING_LINE
from tabulate import SEPARATING_LINE, simple_separated_format, tabulate

from common import assert_equal, check_warnings, raises, skip

# _test_table shows
# - coercion of a string to a number,
Expand Down
3 changes: 2 additions & 1 deletion test/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Regression tests."""

from tabulate import tabulate, TableFormat, Line, DataRow
from tabulate import DataRow, Line, TableFormat, tabulate

from common import assert_equal, skip


Expand Down
6 changes: 3 additions & 3 deletions test/test_textwrapper.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Discretely test functionality of our custom TextWrapper"""

import datetime

from tabulate import _CustomTextWrap as CTW, tabulate, _strip_ansi
from textwrap import TextWrapper as OTW

from common import skip, assert_equal
from tabulate import _CustomTextWrap as CTW, _strip_ansi, tabulate

from common import assert_equal, skip


def test_wrap_multiword_non_wide():
Expand Down