Skip to content

Commit 600bced

Browse files
authored
Merge branch 'master' into patch-1
2 parents 2d3c3df + cecb08e commit 600bced

21 files changed

+719
-273
lines changed

.circleci/config.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.circleci/requirements.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: lint
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ['3.12']
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install tox tox-gh
24+
- name: Run linters
25+
run: |
26+
tox -e lint

.github/workflows/tabulate.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: pytest
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
allow-prereleases: true
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
python -m pip install pytest numpy pandas
25+
- name: Run tests
26+
run: |
27+
pytest -v --doctest-modules --ignore benchmark/benchmark.py

CHANGELOG

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
- 0.9.1: Future version.
1+
- 0.10.0: Add support for Python 3.11, 3.12, 3.13.
2+
Drop support for Python 3.7, 3.8.
3+
PRESERVE_STERILITY global is replaced with preserve_sterility function argument.
4+
New formatting options: headersglobalalign, headersalign, colglobalalign.
5+
New output format: ``colon_grid`` (Pandoc grid_tables with alignment)
6+
Various bug fixes.
7+
Improved error messages.
28
- 0.9.0: Drop support for Python 2.7, 3.5, 3.6.
39
Migrate to pyproject.toml project layout (PEP 621).
410
New output formats: `asciidoc`, various `*grid` and `*outline` formats.

HOWTOPUBLISH

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# update contributors and CHANGELOG in README
2+
python -m pre_commit run -a # and then commit changes
3+
tox -e py39-extra,py310-extra,py311-extra,py312-extra,py313-extra
24
# tag version release
3-
python3 benchmark.py # then update README
4-
tox -e py37-extra,py38-extra,py39-extra,py310-extra
5-
python3 -m build -nswx .
5+
python -m build -s # this will update tabulate/version.py
6+
python -m pip install . # install tabulate in the current venv
7+
python -m pip install -r benchmark/requirements.txt
8+
python benchmark/benchmark.py # then update README
9+
# move tag to the last commit
10+
python -m build -s # update tabulate/version.py
11+
python -m build -nswx .
12+
git push # wait for all CI builds to succeed
13+
git push --tags # if CI builds succeed
614
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
715
twine upload dist/*

README.md

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pip install tabulate
5353
Build status
5454
------------
5555

56-
[![Build status](https://circleci.com/gh/astanin/python-tabulate.svg?style=svg)](https://circleci.com/gh/astanin/python-tabulate/tree/master) [![Build status](https://ci.appveyor.com/api/projects/status/8745yksvvol7h3d7/branch/master?svg=true)](https://ci.appveyor.com/project/astanin/python-tabulate/branch/master)
56+
[![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)
5757

5858
Library usage
5959
-------------
@@ -81,7 +81,7 @@ The following tabular data types are supported:
8181
- list of lists or another iterable of iterables
8282
- list or another iterable of dicts (keys as columns)
8383
- dict of iterables (keys as columns)
84-
- list of dataclasses (Python 3.7+ only, field names as columns)
84+
- list of dataclasses (field names as columns)
8585
- two-dimensional NumPy array
8686
- NumPy record arrays (names as columns)
8787
- pandas.DataFrame
@@ -121,10 +121,22 @@ dictionaries or named tuples:
121121
```pycon
122122
>>> print(tabulate({"Name": ["Alice", "Bob"],
123123
... "Age": [24, 19]}, headers="keys"))
124-
Age Name
125-
----- ------
126-
24 Alice
127-
19 Bob
124+
Name Age
125+
------ -----
126+
Alice 24
127+
Bob 19
128+
```
129+
130+
When data is a list of dictionaries, a dictionary can be passed as `headers`
131+
to replace the keys with other column labels:
132+
133+
```pycon
134+
>>> print(tabulate([{1: "Alice", 2: 24}, {1: "Bob", 2: 19}],
135+
... headers={1: "Name", 2: "Age"}))
136+
Name Age
137+
------ -----
138+
Alice 24
139+
Bob 19
128140
```
129141

130142
### Row Indices
@@ -323,6 +335,22 @@ corresponds to the `pipe` format without alignment colons:
323335
╘════════╧═══════╛
324336
```
325337

338+
`colon_grid` is similar to `grid` but uses colons only to define
339+
columnwise content alignment , without whitespace padding,
340+
similar the alignment specification of Pandoc `grid_tables`:
341+
342+
>>> print(tabulate([["spam", 41.9999], ["eggs", "451.0"]],
343+
... ["strings", "numbers"], "colon_grid",
344+
... colalign=["right", "left"]))
345+
+-----------+-----------+
346+
| strings | numbers |
347+
+==========:+:==========+
348+
| spam | 41.9999 |
349+
+-----------+-----------+
350+
| eggs | 451 |
351+
+-----------+-----------+
352+
353+
326354
`outline` is the same as the `grid` format but doesn't draw lines between rows:
327355

328356
>>> print(tabulate(table, headers, tablefmt="outline"))
@@ -727,13 +755,8 @@ column, in which case every column may have different number formatting:
727755
### Text formatting
728756

729757
By default, `tabulate` removes leading and trailing whitespace from text
730-
columns. To disable whitespace removal, set the global module-level flag
731-
`PRESERVE_WHITESPACE`:
732-
733-
```python
734-
import tabulate
735-
tabulate.PRESERVE_WHITESPACE = True
736-
```
758+
columns. To disable whitespace removal, pass `preserve_whitespace=True`.
759+
Older versions of the library used a global module-level flag PRESERVE_WHITESPACE.
737760

738761
### Wide (fullwidth CJK) symbols
739762

@@ -1036,21 +1059,19 @@ simply joining lists of values with a tab, comma, or other separator.
10361059

10371060
At the same time, `tabulate` is comparable to other table
10381061
pretty-printers. Given a 10x10 table (a list of lists) of mixed text and
1039-
numeric data, `tabulate` appears to be slower than `asciitable`, and
1040-
faster than `PrettyTable` and `texttable` The following mini-benchmark
1041-
was run in Python 3.9.13 on Windows 10:
1042-
1043-
================================= ========== ===========
1044-
Table formatter time, μs rel. time
1045-
================================= ========== ===========
1046-
csv to StringIO 12.5 1.0
1047-
join with tabs and newlines 14.6 1.2
1048-
asciitable (0.8.0) 192.0 15.4
1049-
tabulate (0.9.0) 483.5 38.7
1050-
tabulate (0.9.0, WIDE_CHARS_MODE) 637.6 51.1
1051-
PrettyTable (3.4.1) 1080.6 86.6
1052-
texttable (1.6.4) 1390.3 111.4
1053-
================================= ========== ===========
1062+
numeric data, `tabulate` appears to be faster than `PrettyTable` and `texttable`.
1063+
The following mini-benchmark was run in Python 3.11.9 on Windows 11 (x64):
1064+
1065+
================================== ========== ===========
1066+
Table formatter time, μs rel. time
1067+
================================== ========== ===========
1068+
join with tabs and newlines 6.3 1.0
1069+
csv to StringIO 6.6 1.0
1070+
tabulate (0.10.0) 249.2 39.3
1071+
tabulate (0.10.0, WIDE_CHARS_MODE) 325.6 51.4
1072+
texttable (1.7.0) 579.3 91.5
1073+
PrettyTable (3.11.0) 605.5 95.6
1074+
================================== ========== ===========
10541075

10551076

10561077
Version history
@@ -1074,33 +1095,33 @@ To run tests on all supported Python versions, make sure all Python
10741095
interpreters, `pytest` and `tox` are installed, then run `tox` in the root
10751096
of the project source tree.
10761097

1077-
On Linux `tox` expects to find executables like `python3.7`, `python3.8` etc.
1078-
On Windows it looks for `C:\Python37\python.exe`, `C:\Python38\python.exe` etc. respectively.
1098+
On Linux `tox` expects to find executables like `python3.11`, `python3.12` etc.
1099+
On Windows it looks for `C:\Python311\python.exe`, `C:\Python312\python.exe` etc. respectively.
10791100

10801101
One way to install all the required versions of the Python interpreter is to use [pyenv](https://github.com/pyenv/pyenv).
10811102
All versions can then be easily installed with something like:
10821103

1083-
pyenv install 3.7.12
1084-
pyenv install 3.8.12
1104+
pyenv install 3.11.7
1105+
pyenv install 3.12.1
10851106
...
10861107

10871108
Don't forget to change your `PATH` so that `tox` knows how to find all the installed versions. Something like
10881109

10891110
export PATH="${PATH}:${HOME}/.pyenv/shims"
10901111

10911112
To test only some Python environments, use `-e` option. For example, to
1092-
test only against Python 3.7 and Python 3.10, run:
1113+
test only against Python 3.11 and Python 3.12, run:
10931114

10941115
```shell
1095-
tox -e py37,py310
1116+
tox -e py311,py312
10961117
```
10971118

10981119
in the root of the project source tree.
10991120

11001121
To enable NumPy and Pandas tests, run:
11011122

11021123
```shell
1103-
tox -e py37-extra,py310-extra
1124+
tox -e py311-extra,py312-extra
11041125
```
11051126

11061127
(this may take a long time the first time, because NumPy and Pandas will
@@ -1133,8 +1154,9 @@ endolith, Dominic Davis-Foster, pavlocat, Daniel Aslau, paulc,
11331154
Felix Yan, Shane Loretz, Frank Busse, Harsh Singh, Derek Weitzel,
11341155
Vladimir Vrzić, 서승우 (chrd5273), Georgy Frolov, Christian Cwienk,
11351156
Bart Broere, Vilhelm Prytz, Alexander Gažo, Hugo van Kemenade,
1136-
jamescooke, Matt Warner, Jérôme Provensal, Kevin Deldycke,
1157+
jamescooke, Matt Warner, Jérôme Provensal, Michał Górny, Kevin Deldycke,
11371158
Kian-Meng Ang, Kevin Patterson, Shodhan Save, cleoold, KOLANICH,
11381159
Vijaya Krishna Kasula, Furcy Pin, Christian Fibich, Shaun Duncan,
1139-
Dimitri Papadopoulos, Élie Goudout.
1140-
1160+
Dimitri Papadopoulos, Élie Goudout, Racerroar888, Phill Zarfos,
1161+
Keyacom, Andrew Coffey, Arpit Jain, Israel Roldan, ilya112358,
1162+
Dan Nicholson, Frederik Scheerer, cdar07 (cdar), Racerroar888.

appveyor.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ environment:
88
# The list here is complete (excluding Python 2.6, which
99
# isn't covered by this document) at the time of writing.
1010

11-
- PYTHON: "C:\\Python37"
12-
- PYTHON: "C:\\Python38"
13-
- PYTHON: "C:\\Python39"
14-
- PYTHON: "C:\\Python37-x64"
15-
- PYTHON: "C:\\Python38-x64"
11+
#- PYTHON: "C:\\Python39"
12+
#- PYTHON: "C:\\Python310"
13+
#- PYTHON: "C:\\Python311"
14+
#- PYTHON: "C:\\Python312"
1615
- PYTHON: "C:\\Python39-x64"
1716
- PYTHON: "C:\\Python310-x64"
1817
- PYTHON: "C:\\Python311-x64"
18+
- PYTHON: "C:\\Python312-x64"
1919

2020
install:
2121
# Newer setuptools is needed for proper support of pyproject.toml
@@ -29,20 +29,15 @@ build: off
2929

3030
test_script:
3131
# Put your test command here.
32-
# If you don't need to build C extensions on 64-bit Python 3.3 or 3.4,
33-
# you can remove "build.cmd" from the front of the command, as it's
34-
# only needed to support those cases.
3532
# Note that you must use the environment variable %PYTHON% to refer to
3633
# the interpreter you're using - Appveyor does not do anything special
3734
# to put the Python version you want to use on PATH.
3835
#- "build.cmd %PYTHON%\\python.exe setup.py test"
39-
- "%PYTHON%\\python.exe -m pytest -v --doctest-modules --ignore benchmark.py"
36+
- "%PYTHON%\\python.exe -m pytest -v --doctest-modules --ignore benchmark\benchmark.py"
4037

4138
after_test:
4239
# This step builds your wheels.
43-
# Again, you only need build.cmd if you're building C extensions for
44-
# 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct
45-
# interpreter
40+
# Again, you need to use %PYTHON% to get the correct interpreter
4641
#- "build.cmd %PYTHON%\\python.exe setup.py bdist_wheel"
4742
- "%PYTHON%\\python.exe -m build -nswx ."
4843

0 commit comments

Comments
 (0)