diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..7e7c906 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,26 @@ +name: lint + +on: + - push + - pull_request + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.12'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh + - name: Run linters + run: | + tox -e lint diff --git a/.github/workflows/github-actions-tox.yml b/.github/workflows/tabulate.yml similarity index 71% rename from .github/workflows/github-actions-tox.yml rename to .github/workflows/tabulate.yml index 35be5cd..9adabb7 100644 --- a/.github/workflows/github-actions-tox.yml +++ b/.github/workflows/tabulate.yml @@ -12,7 +12,7 @@ jobs: python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -20,6 +20,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - name: Test with tox - run: tox + python -m pip install pytest numpy pandas + - name: Run tests + run: | + pytest -v --doctest-modules --ignore benchmark.py diff --git a/README.md b/README.md index 39c3863..b596cf5 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ pip install tabulate Build status ------------ -[![python-tabulate](https://github.com/astanin/python-tabulate/actions/workflows/github-actions-tox.yml/badge.svg)](https://github.com/astanin/python-tabulate/actions/workflows/github-actions-tox.yml) [![Build status](https://ci.appveyor.com/api/projects/status/8745yksvvol7h3d7/branch/master?svg=true)](https://ci.appveyor.com/project/astanin/python-tabulate/branch/master) +[![python-tabulate](https://github.com/astanin/python-tabulate/actions/workflows/tabulate.yml/badge.svg)](https://github.com/astanin/python-tabulate/actions/workflows/tabulate.yml) [![Build status](https://ci.appveyor.com/api/projects/status/8745yksvvol7h3d7/branch/master?svg=true)](https://ci.appveyor.com/project/astanin/python-tabulate/branch/master) Library usage ------------- diff --git a/tabulate/__init__.py b/tabulate/__init__.py index 3883b96..1099b7c 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -104,7 +104,7 @@ def _is_file(f): def _is_separating_line_value(value): - return type(value) == str and value.strip() == SEPARATING_LINE + return type(value) is str and value.strip() == SEPARATING_LINE def _is_separating_line(row): @@ -2770,7 +2770,7 @@ def _main(): print(usage) sys.exit(0) files = [sys.stdin] if not args else args - with (sys.stdout if outfile == "-" else open(outfile, "w")) as out: + with sys.stdout if outfile == "-" else open(outfile, "w") as out: for f in files: if f == "-": f = sys.stdin diff --git a/test/test_cli.py b/test/test_cli.py index ce85f19..e71572d 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -2,7 +2,6 @@ """ - import os import sys diff --git a/test/test_internal.py b/test/test_internal.py index 64e1d12..e7564d3 100644 --- a/test/test_internal.py +++ b/test/test_internal.py @@ -182,7 +182,12 @@ def test_wrap_text_wide_chars(): rows = [["청자청자청자청자청자", "약간 감싸면 더 잘 보일 수있는 다소 긴 설명입니다"]] widths = [5, 20] - expected = [["청자\n청자\n청자\n청자\n청자", "약간 감싸면 더 잘\n보일 수있는 다소 긴\n설명입니다"]] + expected = [ + [ + "청자\n청자\n청자\n청자\n청자", + "약간 감싸면 더 잘\n보일 수있는 다소 긴\n설명입니다", + ] + ] result = T._wrap_text_to_colwidths(rows, widths) assert_equal(expected, result) diff --git a/test/test_output.py b/test/test_output.py index ee03522..1ca8208 100644 --- a/test/test_output.py +++ b/test/test_output.py @@ -137,7 +137,10 @@ def test_plain_maxcolwidth_autowraps_wide_chars(): table = [ ["hdr", "fold"], - ["1", "약간 감싸면 더 잘 보일 수있는 다소 긴 설명입니다 설명입니다 설명입니다 설명입니다 설명"], + [ + "1", + "약간 감싸면 더 잘 보일 수있는 다소 긴 설명입니다 설명입니다 설명입니다 설명입니다 설명", + ], ] expected = "\n".join( [ diff --git a/test/test_textwrapper.py b/test/test_textwrapper.py index 88420be..b315a5c 100644 --- a/test/test_textwrapper.py +++ b/test/test_textwrapper.py @@ -142,7 +142,8 @@ def test_wrap_color_in_single_line(): def test_wrap_color_line_splillover(): """TextWrapper: Wrap a line - preserve internal color tags and wrap them to - other lines when required, requires adding the colors tags to other lines as appropriate""" + other lines when required, requires adding the colors tags to other lines as appropriate + """ # This has both a text color and a background color data = "This is a \033[31mtest string for testing TextWrap\033[0m with colors" diff --git a/tox.ini b/tox.ini index 92939c2..a7fe513 100644 --- a/tox.ini +++ b/tox.ini @@ -11,12 +11,12 @@ envlist = lint, py{38, 39, 310, 311, 312} isolated_build = True -[gh-actions] +[gh] python = - 3.9: py39 - 3.10: py310 - 3.11: py311 - 3.12: py312 + 3.9: py39-extra + 3.10: py310-extra + 3.11: py311-extra + 3.12: py312-extra [testenv] commands = pytest -v --doctest-modules --ignore benchmark.py {posargs}