prettytable 3.16.0__tar.gz → 3.17.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/labels.yml +1 -1
  2. {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/lint.yml +6 -6
  3. {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/release.yml +3 -3
  4. {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/test.yml +21 -7
  5. prettytable-3.17.0/.github/zizmor.yml +7 -0
  6. {prettytable-3.16.0 → prettytable-3.17.0}/.pre-commit-config.yaml +10 -10
  7. {prettytable-3.16.0 → prettytable-3.17.0}/PKG-INFO +62 -47
  8. {prettytable-3.16.0 → prettytable-3.17.0}/README.md +59 -44
  9. {prettytable-3.16.0 → prettytable-3.17.0}/pyproject.toml +9 -4
  10. prettytable-3.17.0/requirements-mypy.txt +3 -0
  11. {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/_version.py +16 -3
  12. {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/prettytable.py +88 -49
  13. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_prettytable.py +189 -1
  14. {prettytable-3.16.0 → prettytable-3.17.0}/tox.ini +3 -7
  15. prettytable-3.16.0/.coveragerc +0 -15
  16. prettytable-3.16.0/requirements-mypy.txt +0 -2
  17. {prettytable-3.16.0 → prettytable-3.17.0}/.github/FUNDING.yml +0 -0
  18. {prettytable-3.16.0 → prettytable-3.17.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  19. {prettytable-3.16.0 → prettytable-3.17.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  20. {prettytable-3.16.0 → prettytable-3.17.0}/.github/SECURITY.md +0 -0
  21. {prettytable-3.16.0 → prettytable-3.17.0}/.github/dependabot.yml +0 -0
  22. {prettytable-3.16.0 → prettytable-3.17.0}/.github/labels.yml +0 -0
  23. {prettytable-3.16.0 → prettytable-3.17.0}/.github/release-drafter.yml +0 -0
  24. {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/release-drafter.yml +0 -0
  25. {prettytable-3.16.0 → prettytable-3.17.0}/.github/workflows/require-pr-label.yml +0 -0
  26. {prettytable-3.16.0 → prettytable-3.17.0}/.gitignore +0 -0
  27. {prettytable-3.16.0 → prettytable-3.17.0}/CHANGELOG.md +0 -0
  28. {prettytable-3.16.0 → prettytable-3.17.0}/LICENSE +0 -0
  29. {prettytable-3.16.0 → prettytable-3.17.0}/RELEASING.md +0 -0
  30. {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/__init__.py +0 -0
  31. {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/__main__.py +0 -0
  32. {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/colortable.py +0 -0
  33. {prettytable-3.16.0 → prettytable-3.17.0}/src/prettytable/py.typed +0 -0
  34. {prettytable-3.16.0 → prettytable-3.17.0}/tests/conftest.py +0 -0
  35. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_colortable.py +0 -0
  36. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_html.py +0 -0
  37. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_json.py +0 -0
  38. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_latex.py +0 -0
  39. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_mediawiki.py +0 -0
  40. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_sections.py +0 -0
  41. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_sorting.py +0 -0
  42. {prettytable-3.16.0 → prettytable-3.17.0}/tests/test_style.py +0 -0
@@ -14,7 +14,7 @@ jobs:
14
14
  pull-requests: write
15
15
  runs-on: ubuntu-latest
16
16
  steps:
17
- - uses: actions/checkout@v4
17
+ - uses: actions/checkout@v5
18
18
  with:
19
19
  persist-credentials: false
20
20
  - uses: micnncim/action-label-syncer@v1
@@ -13,25 +13,25 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
 
15
15
  steps:
16
- - uses: actions/checkout@v4
16
+ - uses: actions/checkout@v5
17
17
  with:
18
18
  persist-credentials: false
19
- - uses: actions/setup-python@v5
19
+ - uses: actions/setup-python@v6
20
20
  with:
21
21
  python-version: "3.x"
22
- - uses: tox-dev/action-pre-commit-uv@v1
22
+ - uses: j178/prek-action@v1
23
23
 
24
24
  mypy:
25
25
  runs-on: ubuntu-latest
26
26
 
27
27
  steps:
28
- - uses: actions/checkout@v4
28
+ - uses: actions/checkout@v5
29
29
  with:
30
30
  persist-credentials: false
31
- - uses: actions/setup-python@v5
31
+ - uses: actions/setup-python@v6
32
32
  with:
33
33
  python-version: "3.x"
34
34
  - name: Install uv
35
- uses: astral-sh/setup-uv@v5
35
+ uses: astral-sh/setup-uv@v7
36
36
  - name: Mypy
37
37
  run: uvx --with tox-uv tox -e mypy
@@ -20,7 +20,7 @@ jobs:
20
20
  runs-on: ubuntu-latest
21
21
 
22
22
  steps:
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v5
24
24
  with:
25
25
  fetch-depth: 0
26
26
  persist-credentials: false
@@ -42,7 +42,7 @@ jobs:
42
42
 
43
43
  steps:
44
44
  - name: Download packages built by build-and-inspect-python-package
45
- uses: actions/download-artifact@v4
45
+ uses: actions/download-artifact@v6
46
46
  with:
47
47
  name: Packages
48
48
  path: dist
@@ -67,7 +67,7 @@ jobs:
67
67
 
68
68
  steps:
69
69
  - name: Download packages built by build-and-inspect-python-package
70
- uses: actions/download-artifact@v4
70
+ uses: actions/download-artifact@v6
71
71
  with:
72
72
  name: Packages
73
73
  path: dist
@@ -6,6 +6,7 @@ permissions: {}
6
6
 
7
7
  env:
8
8
  FORCE_COLOR: 1
9
+ PIP_DISABLE_PIP_VERSION_CHECK: 1
9
10
 
10
11
  jobs:
11
12
  test:
@@ -13,28 +14,41 @@ jobs:
13
14
  strategy:
14
15
  fail-fast: false
15
16
  matrix:
16
- python-version: ["pypy3.11", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
17
+ python-version:
18
+ - "pypy3.11"
19
+ - "3.15t"
20
+ - "3.15"
21
+ - "3.14t"
22
+ - "3.14"
23
+ - "3.13t"
24
+ - "3.13"
25
+ - "3.12"
26
+ - "3.11"
27
+ - "3.10"
17
28
  os: [windows-latest, macos-latest, ubuntu-latest]
18
29
 
19
30
  steps:
20
- - uses: actions/checkout@v4
31
+ - uses: actions/checkout@v5
21
32
  with:
22
33
  persist-credentials: false
23
34
 
24
35
  - name: Set up Python ${{ matrix.python-version }}
25
- uses: actions/setup-python@v5
36
+ uses: actions/setup-python@v6
26
37
  with:
27
38
  python-version: ${{ matrix.python-version }}
28
39
  allow-prereleases: true
29
40
 
41
+ - name: Set PYTHON_GIL
42
+ if: endsWith(matrix.python-version, 't')
43
+ run: |
44
+ echo "PYTHON_GIL=0" >> "$GITHUB_ENV"
45
+
30
46
  - name: Install uv
31
- uses: astral-sh/setup-uv@v5
32
- with:
33
- cache-dependency-glob: "**/pyproject.toml"
47
+ uses: astral-sh/setup-uv@v7
34
48
 
35
49
  - name: Tox tests
36
50
  run: |
37
- uvx --with tox-uv tox -e py
51
+ uvx --python ${{ matrix.python-version }} --with tox-uv tox -e py
38
52
 
39
53
  - name: Upload coverage
40
54
  uses: codecov/codecov-action@v5
@@ -0,0 +1,7 @@
1
+ # Configuration for the zizmor static analysis tool, run via pre-commit in CI
2
+ # https://woodruffw.github.io/zizmor/configuration/
3
+ rules:
4
+ unpinned-uses:
5
+ config:
6
+ policies:
7
+ "*": ref-pin
@@ -1,17 +1,17 @@
1
1
  repos:
2
2
  - repo: https://github.com/astral-sh/ruff-pre-commit
3
- rev: v0.9.2
3
+ rev: v0.13.3
4
4
  hooks:
5
- - id: ruff
5
+ - id: ruff-check
6
6
  args: [--exit-non-zero-on-fix]
7
7
 
8
8
  - repo: https://github.com/psf/black-pre-commit-mirror
9
- rev: 24.10.0
9
+ rev: 25.9.0
10
10
  hooks:
11
11
  - id: black
12
12
 
13
13
  - repo: https://github.com/pre-commit/pre-commit-hooks
14
- rev: v5.0.0
14
+ rev: v6.0.0
15
15
  hooks:
16
16
  - id: check-added-large-files
17
17
  - id: check-case-conflict
@@ -26,7 +26,7 @@ repos:
26
26
  exclude: .github/ISSUE_TEMPLATE/bug_report.md|tests/test_style.py|tests/test_prettytable.py
27
27
 
28
28
  - repo: https://github.com/python-jsonschema/check-jsonschema
29
- rev: 0.31.0
29
+ rev: 0.34.0
30
30
  hooks:
31
31
  - id: check-dependabot
32
32
  - id: check-github-workflows
@@ -37,27 +37,27 @@ repos:
37
37
  - id: actionlint
38
38
 
39
39
  - repo: https://github.com/woodruffw/zizmor-pre-commit
40
- rev: v1.2.2
40
+ rev: v1.14.2
41
41
  hooks:
42
42
  - id: zizmor
43
43
 
44
44
  - repo: https://github.com/tox-dev/pyproject-fmt
45
- rev: v2.5.0
45
+ rev: v2.7.0
46
46
  hooks:
47
47
  - id: pyproject-fmt
48
48
 
49
49
  - repo: https://github.com/abravalheri/validate-pyproject
50
- rev: v0.23
50
+ rev: v0.24.1
51
51
  hooks:
52
52
  - id: validate-pyproject
53
53
 
54
54
  - repo: https://github.com/tox-dev/tox-ini-fmt
55
- rev: 1.5.0
55
+ rev: 1.6.0
56
56
  hooks:
57
57
  - id: tox-ini-fmt
58
58
 
59
59
  - repo: https://github.com/rbubley/mirrors-prettier
60
- rev: v3.4.2
60
+ rev: v3.6.2
61
61
  hooks:
62
62
  - id: prettier
63
63
  args: [--prose-wrap=always, --print-width=88]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prettytable
3
- Version: 3.16.0
3
+ Version: 3.17.0
4
4
  Summary: A simple Python library for easily displaying tabular data in a visually appealing ASCII table format
5
5
  Project-URL: Changelog, https://github.com/prettytable/prettytable/releases
6
6
  Project-URL: Funding, https://tidelift.com/subscription/pkg/pypi-prettytable?utm_source=pypi-prettytable&utm_medium=pypi
@@ -12,17 +12,17 @@ License-Expression: BSD-3-Clause
12
12
  License-File: LICENSE
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
19
18
  Classifier: Programming Language :: Python :: 3.13
20
19
  Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
21
21
  Classifier: Programming Language :: Python :: Implementation :: CPython
22
22
  Classifier: Programming Language :: Python :: Implementation :: PyPy
23
23
  Classifier: Topic :: Text Processing
24
24
  Classifier: Typing :: Typed
25
- Requires-Python: >=3.9
25
+ Requires-Python: >=3.10
26
26
  Requires-Dist: wcwidth
27
27
  Provides-Extra: tests
28
28
  Requires-Dist: pytest; extra == 'tests'
@@ -310,11 +310,11 @@ keyword argument, which must be a function with one argument `row` returning a B
310
310
  value. The `row` is the list of fields in a row.
311
311
 
312
312
  For example, to print the example table we built earlier of Australian capital city
313
- data, so that cities with a population with more than 1,000,000, we can do this:
313
+ data, so that cities with a population of at least 1,000,000, we can do this:
314
314
 
315
315
  ```python
316
- def filter_function(self, vals: list[str]) -> bool:
317
- return vals[2] > 999999
316
+ def filter_function(row: list[str]) -> bool:
317
+ return row[2] > 999999
318
318
 
319
319
  print(table.get_string(row_filter=filter_function))
320
320
  ```
@@ -444,13 +444,15 @@ table.sortby = None
444
444
  ```
445
445
 
446
446
  If you want to specify a custom sorting function, you can use the `sort_key` keyword
447
- argument. Pass this a function which accepts two lists of values and returns a negative
448
- or positive value depending on whether the first list should appear before or after the
449
- second one. If your table has n columns, each list will have n+1 elements. Each list
450
- corresponds to one row of the table. The first element will be whatever data is in the
451
- relevant row, in the column specified by the `sort_by` argument. The remaining n
452
- elements are the data in each of the table's columns, in order, including a repeated
453
- instance of the data in the `sort_by` column.
447
+ argument as Pythons `sorted()` `key` parameter. The value of the `sort_key` parameter
448
+ should be a function (or other callable) that takes a single argument and returns a key
449
+ to use for sorting purposes.
450
+
451
+ If your table has n columns, each list will have n+1 elements. Each list corresponds to
452
+ one row of the table. The first element will be whatever data is in the relevant row, in
453
+ the column specified by the `sort_by` argument. The remaining n elements are the data in
454
+ each of the table's columns, in order, including a repeated instance of the data in the
455
+ `sort_by` column.
454
456
 
455
457
  #### Adding sections to a table
456
458
 
@@ -541,40 +543,53 @@ PrettyTable has a number of style options which control various aspects of how t
541
543
  are displayed. You have the freedom to set each of these options individually to
542
544
  whatever you prefer. The `set_style` method just does this automatically for you.
543
545
 
544
- The options are:
545
-
546
- | Option | Details |
547
- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
548
- | `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
549
- | `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
550
- | `header` | A Boolean option (must be `True` or `False`). Controls whether the first row of the table is a header showing the names of all the fields. |
551
- | `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
552
- | `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
553
- | `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
554
- | `int_format` | A string which controls the way integer data is printed. This works like: `print("%<int_format>d" % data)`. |
555
- | `float_format` | A string which controls the way floating point data is printed. This works like: `print("%<float_format>f" % data)`. |
556
- | `custom_format` | A dictionary of field and callable. This allows you to set any format you want `pf.custom_format["my_col_int"] = lambda f, v: f"{v:,}"`. The type of the callable is `Callable[[str, Any], str]` |
557
- | `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
558
- | `left_padding_width` | Number of spaces on left-hand side of column data. |
559
- | `right_padding_width` | Number of spaces on right-hand side of column data. |
560
- | `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
561
- | `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
562
- | `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
563
- | `junction_char` | Single character string used to draw line junctions. Default: `+`. |
564
- | `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
565
- | `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
566
- | `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
567
- | `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
568
- | `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
569
- | `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
570
- | `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
571
- | `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
572
- | `min_table_width` | Number of characters used for the minimum total table width. |
573
- | `max_table_width` | Number of characters used for the maximum total table width. |
574
- | `max_width` | Number of characters used for maximum width of a column. |
575
- | `min_width` | Number of characters used for minimum width of a column. |
576
- | `use_header_width` | A Boolean option (must be `True` or `False`). Controls whether the width of the header is used for computing column width. Default: `True`. |
577
- | `break_on_hyphens` | Whether long lines are wrapped on hyphens. Default: `True`. |
546
+ Table-specific options are:
547
+
548
+ | Option | Details |
549
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
550
+ | `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
551
+ | `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
552
+ | `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
553
+ | `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
554
+ | `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
555
+ | `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
556
+ | `break_on_hyphens` | Whether long lines are wrapped on hyphens. Default: `True`. |
557
+ | `header` | A Boolean option (must be `True` or `False`). Controls whether the first row of the table is a header showing the names of all the fields. |
558
+ | `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
559
+ | `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
560
+ | `junction_char` | Single character string used to draw line junctions. Default: `+`. |
561
+ | `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
562
+ | `left_padding_width` | Number of spaces on left-hand side of column data. |
563
+ | `max_table_width` | Number of characters used for the maximum total table width. |
564
+ | `min_table_width` | Number of characters used for the minimum total table width. |
565
+ | `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
566
+ | `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
567
+ | `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
568
+ | `right_padding_width` | Number of spaces on right-hand side of column data. |
569
+ | `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
570
+ | `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
571
+ | `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
572
+ | `use_header_width` | A Boolean option (must be `True` or `False`). Controls whether the width of the header is used for computing column width. Default: `True`. |
573
+ | `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
574
+ | `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
575
+
576
+ For options that can be set individually for each column (`align`, `valign`,
577
+ `custom_format`, `max_width`, `min_width`, `int_format`, `float_format`, `none_format`)
578
+ you can either set a value, that applies to all columns or set a dict with column names
579
+ and individual values.
580
+
581
+ Column-specific options are:
582
+
583
+ | Option | Details |
584
+ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
585
+ | `align` | Controls alignment of fields, one of "l", "c", or "r" or a dictionary with column and value. |
586
+ | `custom_format` | Set any format, by setting a function that gets the original value,the formatted representation and returns the new string. E.g. `pf.custom_format["my_col_int"] = lambda f, v: f"{v:,}"`. The type of the callable is `Callable[[str, Any], str]`. This also takes a dictionary with column and function. |
587
+ | `float_format` | A string which controls the way floating point data is printed or a dictionary with column and value. This works like: `print("%<float_format>f" % data)`. |
588
+ | `int_format` | A string which controls the way integer data is printed or a dictionary with column and value. This works like: `print("%<int_format>d" % data)`. |
589
+ | `max_width` | Number of characters used for maximum width of a column or a dictionary with column and value. |
590
+ | `min_width` | Number of characters used for minimum width of a column or a dictionary with column and value. |
591
+ | `none_format` | Representation of None values or a dictionary with column and value. |
592
+ | `valign` | Controls vertical alignment of fields, one of "t", "m", or "b" or a dictionary with column and value. |
578
593
 
579
594
  You can set the style options to your own settings in two ways:
580
595
 
@@ -278,11 +278,11 @@ keyword argument, which must be a function with one argument `row` returning a B
278
278
  value. The `row` is the list of fields in a row.
279
279
 
280
280
  For example, to print the example table we built earlier of Australian capital city
281
- data, so that cities with a population with more than 1,000,000, we can do this:
281
+ data, so that cities with a population of at least 1,000,000, we can do this:
282
282
 
283
283
  ```python
284
- def filter_function(self, vals: list[str]) -> bool:
285
- return vals[2] > 999999
284
+ def filter_function(row: list[str]) -> bool:
285
+ return row[2] > 999999
286
286
 
287
287
  print(table.get_string(row_filter=filter_function))
288
288
  ```
@@ -412,13 +412,15 @@ table.sortby = None
412
412
  ```
413
413
 
414
414
  If you want to specify a custom sorting function, you can use the `sort_key` keyword
415
- argument. Pass this a function which accepts two lists of values and returns a negative
416
- or positive value depending on whether the first list should appear before or after the
417
- second one. If your table has n columns, each list will have n+1 elements. Each list
418
- corresponds to one row of the table. The first element will be whatever data is in the
419
- relevant row, in the column specified by the `sort_by` argument. The remaining n
420
- elements are the data in each of the table's columns, in order, including a repeated
421
- instance of the data in the `sort_by` column.
415
+ argument as Pythons `sorted()` `key` parameter. The value of the `sort_key` parameter
416
+ should be a function (or other callable) that takes a single argument and returns a key
417
+ to use for sorting purposes.
418
+
419
+ If your table has n columns, each list will have n+1 elements. Each list corresponds to
420
+ one row of the table. The first element will be whatever data is in the relevant row, in
421
+ the column specified by the `sort_by` argument. The remaining n elements are the data in
422
+ each of the table's columns, in order, including a repeated instance of the data in the
423
+ `sort_by` column.
422
424
 
423
425
  #### Adding sections to a table
424
426
 
@@ -509,40 +511,53 @@ PrettyTable has a number of style options which control various aspects of how t
509
511
  are displayed. You have the freedom to set each of these options individually to
510
512
  whatever you prefer. The `set_style` method just does this automatically for you.
511
513
 
512
- The options are:
513
-
514
- | Option | Details |
515
- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
516
- | `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
517
- | `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
518
- | `header` | A Boolean option (must be `True` or `False`). Controls whether the first row of the table is a header showing the names of all the fields. |
519
- | `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
520
- | `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
521
- | `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
522
- | `int_format` | A string which controls the way integer data is printed. This works like: `print("%<int_format>d" % data)`. |
523
- | `float_format` | A string which controls the way floating point data is printed. This works like: `print("%<float_format>f" % data)`. |
524
- | `custom_format` | A dictionary of field and callable. This allows you to set any format you want `pf.custom_format["my_col_int"] = lambda f, v: f"{v:,}"`. The type of the callable is `Callable[[str, Any], str]` |
525
- | `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
526
- | `left_padding_width` | Number of spaces on left-hand side of column data. |
527
- | `right_padding_width` | Number of spaces on right-hand side of column data. |
528
- | `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
529
- | `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
530
- | `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
531
- | `junction_char` | Single character string used to draw line junctions. Default: `+`. |
532
- | `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
533
- | `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
534
- | `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
535
- | `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
536
- | `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
537
- | `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
538
- | `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
539
- | `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
540
- | `min_table_width` | Number of characters used for the minimum total table width. |
541
- | `max_table_width` | Number of characters used for the maximum total table width. |
542
- | `max_width` | Number of characters used for maximum width of a column. |
543
- | `min_width` | Number of characters used for minimum width of a column. |
544
- | `use_header_width` | A Boolean option (must be `True` or `False`). Controls whether the width of the header is used for computing column width. Default: `True`. |
545
- | `break_on_hyphens` | Whether long lines are wrapped on hyphens. Default: `True`. |
514
+ Table-specific options are:
515
+
516
+ | Option | Details |
517
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
518
+ | `HEADER`, `ALL`, `NONE` | These are variables defined inside the `prettytable` module so make sure you import them or use `prettytable.FRAME` etc. |
519
+ | `_horizontal_align_char` | Single character string used to indicate column alignment in horizontal lines. Default: `:` for Markdown, otherwise `None`. |
520
+ | `border` | A Boolean option (must be `True` or `False`). Controls whether a border is drawn inside and around the table. |
521
+ | `bottom_junction_char` | single character string used to draw bottom line junctions. Default: `junction_char`. |
522
+ | `bottom_left_junction_char` | Single character string used to draw bottom-left line junctions. Default: `junction_char`. |
523
+ | `bottom_right_junction_char` | Single character string used to draw bottom-right line junctions. Default: `junction_char`. |
524
+ | `break_on_hyphens` | Whether long lines are wrapped on hyphens. Default: `True`. |
525
+ | `header` | A Boolean option (must be `True` or `False`). Controls whether the first row of the table is a header showing the names of all the fields. |
526
+ | `horizontal_char` | Single character string used to draw horizontal lines. Default: `-`. |
527
+ | `hrules` | Controls printing of horizontal rules after rows. Allowed values: `FRAME`, `HEADER`, `ALL`, `NONE`. |
528
+ | `junction_char` | Single character string used to draw line junctions. Default: `+`. |
529
+ | `left_junction_char` | Single character string used to draw left line junctions. Default: `junction_char`. |
530
+ | `left_padding_width` | Number of spaces on left-hand side of column data. |
531
+ | `max_table_width` | Number of characters used for the maximum total table width. |
532
+ | `min_table_width` | Number of characters used for the minimum total table width. |
533
+ | `padding_width` | Number of spaces on either side of column data (only used if left and right paddings are `None`). |
534
+ | `preserve_internal_border` | A Boolean option (must be `True` or `False`). Controls whether borders are still drawn within the table even when `border=False`. |
535
+ | `right_junction_char` | Single character string used to draw right line junctions. Default: `junction_char`. |
536
+ | `right_padding_width` | Number of spaces on right-hand side of column data. |
537
+ | `top_junction_char` | Single character string used to draw top line junctions. Default: `junction_char`. |
538
+ | `top_left_junction_char` | Single character string used to draw top-left line junctions. Default: `junction_char`. |
539
+ | `top_right_junction_char` | Single character string used to draw top-right line junctions. Default: `junction_char`. |
540
+ | `use_header_width` | A Boolean option (must be `True` or `False`). Controls whether the width of the header is used for computing column width. Default: `True`. |
541
+ | `vertical_char` | Single character string used to draw vertical lines. Default: `\|`. |
542
+ | `vrules` | Controls printing of vertical rules between columns. Allowed values: `FRAME`, `ALL`, `NONE`. |
543
+
544
+ For options that can be set individually for each column (`align`, `valign`,
545
+ `custom_format`, `max_width`, `min_width`, `int_format`, `float_format`, `none_format`)
546
+ you can either set a value, that applies to all columns or set a dict with column names
547
+ and individual values.
548
+
549
+ Column-specific options are:
550
+
551
+ | Option | Details |
552
+ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
553
+ | `align` | Controls alignment of fields, one of "l", "c", or "r" or a dictionary with column and value. |
554
+ | `custom_format` | Set any format, by setting a function that gets the original value,the formatted representation and returns the new string. E.g. `pf.custom_format["my_col_int"] = lambda f, v: f"{v:,}"`. The type of the callable is `Callable[[str, Any], str]`. This also takes a dictionary with column and function. |
555
+ | `float_format` | A string which controls the way floating point data is printed or a dictionary with column and value. This works like: `print("%<float_format>f" % data)`. |
556
+ | `int_format` | A string which controls the way integer data is printed or a dictionary with column and value. This works like: `print("%<int_format>d" % data)`. |
557
+ | `max_width` | Number of characters used for maximum width of a column or a dictionary with column and value. |
558
+ | `min_width` | Number of characters used for minimum width of a column or a dictionary with column and value. |
559
+ | `none_format` | Representation of None values or a dictionary with column and value. |
560
+ | `valign` | Controls vertical alignment of fields, one of "t", "m", or "b" or a dictionary with column and value. |
546
561
 
547
562
  You can set the style options to your own settings in two ways:
548
563
 
@@ -13,16 +13,16 @@ license = "BSD-3-Clause"
13
13
  license-files = [ "LICENSE" ]
14
14
  maintainers = [ { name = "Hugo van Kemenade" } ]
15
15
  authors = [ { name = "Luke Maurits", email = "luke@maurits.id.au" } ]
16
- requires-python = ">=3.9"
16
+ requires-python = ">=3.10"
17
17
  classifiers = [
18
18
  "Programming Language :: Python",
19
19
  "Programming Language :: Python :: 3 :: Only",
20
- "Programming Language :: Python :: 3.9",
21
20
  "Programming Language :: Python :: 3.10",
22
21
  "Programming Language :: Python :: 3.11",
23
22
  "Programming Language :: Python :: 3.12",
24
23
  "Programming Language :: Python :: 3.13",
25
24
  "Programming Language :: Python :: 3.14",
25
+ "Programming Language :: Python :: 3.15",
26
26
  "Programming Language :: Python :: Implementation :: CPython",
27
27
  "Programming Language :: Python :: Implementation :: PyPy",
28
28
  "Topic :: Text Processing",
@@ -86,7 +86,7 @@ lint.isort.known-first-party = [ "prettytable" ]
86
86
  lint.isort.required-imports = [ "from __future__ import annotations" ]
87
87
 
88
88
  [tool.pyproject-fmt]
89
- max_supported_python = "3.14"
89
+ max_supported_python = "3.15"
90
90
 
91
91
  [tool.pytest.ini_options]
92
92
  filterwarnings = [
@@ -94,8 +94,13 @@ filterwarnings = [
94
94
  ]
95
95
  testpaths = [ "tests" ]
96
96
 
97
+ [tool.coverage.run]
98
+ omit = [
99
+ "**/__main__.py",
100
+ ]
101
+
97
102
  [tool.mypy]
98
- python_version = "3.9"
103
+ python_version = "3.10"
99
104
  pretty = true
100
105
  disallow_any_generics = true
101
106
  enable_error_code = "ignore-without-code"
@@ -0,0 +1,3 @@
1
+ mypy==1.18.2
2
+ types-colorama
3
+ wcwidth-stubs
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '3.16.0'
21
- __version_tuple__ = version_tuple = (3, 16, 0)
31
+ __version__ = version = '3.17.0'
32
+ __version_tuple__ = version_tuple = (3, 17, 0)
33
+
34
+ __commit_id__ = commit_id = None