table2ascii 1.0.4__tar.gz → 1.1.1__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 (31) hide show
  1. {table2ascii-1.0.4/table2ascii.egg-info → table2ascii-1.1.1}/PKG-INFO +30 -25
  2. {table2ascii-1.0.4 → table2ascii-1.1.1}/README.md +29 -24
  3. {table2ascii-1.0.4 → table2ascii-1.1.1}/pyproject.toml +4 -3
  4. table2ascii-1.1.1/setup.py +7 -0
  5. table2ascii-1.1.1/table2ascii/__init__.py +56 -0
  6. table2ascii-1.1.1/table2ascii/alignment.py +73 -0
  7. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii/annotations.py +3 -5
  8. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii/exceptions.py +23 -18
  9. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii/options.py +6 -1
  10. table2ascii-1.1.1/table2ascii/py.typed +1 -0
  11. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii/table_style.py +1 -1
  12. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii/table_to_ascii.py +139 -22
  13. {table2ascii-1.0.4 → table2ascii-1.1.1/table2ascii.egg-info}/PKG-INFO +30 -25
  14. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii.egg-info/SOURCES.txt +9 -1
  15. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii.egg-info/requires.txt +3 -2
  16. table2ascii-1.1.1/tests/test_alignments.py +192 -0
  17. table2ascii-1.1.1/tests/test_cell_padding.py +83 -0
  18. table2ascii-1.1.1/tests/test_column_widths.py +110 -0
  19. table2ascii-1.1.1/tests/test_convert.py +307 -0
  20. table2ascii-1.1.1/tests/test_heading_cols.py +113 -0
  21. table2ascii-1.1.1/tests/test_merge.py +175 -0
  22. table2ascii-1.1.1/tests/test_styles.py +113 -0
  23. table2ascii-1.0.4/setup.py +0 -16
  24. table2ascii-1.0.4/table2ascii/__init__.py +0 -19
  25. table2ascii-1.0.4/table2ascii/alignment.py +0 -34
  26. {table2ascii-1.0.4 → table2ascii-1.1.1}/LICENSE +0 -0
  27. {table2ascii-1.0.4 → table2ascii-1.1.1}/setup.cfg +0 -0
  28. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii/merge.py +0 -0
  29. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii/preset_style.py +0 -0
  30. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii.egg-info/dependency_links.txt +0 -0
  31. {table2ascii-1.0.4 → table2ascii-1.1.1}/table2ascii.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: table2ascii
3
- Version: 1.0.4
3
+ Version: 1.1.1
4
4
  Summary: Convert 2D Python lists into Unicode/ASCII tables
5
5
  Author-email: Jonah Lawrence <jonah@freshidea.com>
6
6
  License: MIT License
@@ -129,22 +129,26 @@ print(output)
129
129
  from table2ascii import table2ascii, Alignment
130
130
 
131
131
  output = table2ascii(
132
- header=["#", "G", "H", "R", "S"],
133
- body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
134
- first_col_heading=True,
135
- column_widths=[5, 5, 5, 5, 5],
136
- alignments=[Alignment.LEFT] + [Alignment.RIGHT] * 4,
132
+ header=["Product", "Category", "Price", "Rating"],
133
+ body=[
134
+ ["Milk", "Dairy", "$2.99", "6.283"],
135
+ ["Cheese", "Dairy", "$10.99", "8.2"],
136
+ ["Apples", "Produce", "$0.99", "10.00"],
137
+ ],
138
+ column_widths=[12, 12, 12, 12],
139
+ alignments=[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.DECIMAL],
137
140
  )
138
141
 
139
142
  print(output)
140
143
 
141
144
  """
142
- ╔═════╦═══════════════════════╗
143
- # G H R S ║
144
- ╟─────╫───────────────────────╢
145
- 1 30 40 35 30 ║
146
- ║ 2 30 40 35 30 ║
147
- ╚═════╩═══════════════════════╝
145
+ ╔═══════════════════════════════════════════════════╗
146
+ Product Category Price Rating
147
+ ╟───────────────────────────────────────────────────╢
148
+ Milk Dairy $2.99 6.283
149
+ Cheese Dairy $10.99 8.2
150
+ ║ Apples Produce $0.99 10.00 ║
151
+ ╚═══════════════════════════════════════════════════╝
148
152
  """
149
153
  ```
150
154
 
@@ -179,7 +183,7 @@ output = table2ascii(
179
183
  body=[["10", "30", "40", "35"], ["20", "10", "20", "5"]],
180
184
  style=PresetStyle.plain,
181
185
  cell_padding=0,
182
- alignments=[Alignment.LEFT] * 4,
186
+ alignments=Alignment.LEFT,
183
187
  )
184
188
 
185
189
  print(output)
@@ -259,18 +263,19 @@ All parameters are optional. At least one of `header`, `body`, and `footer` must
259
263
 
260
264
  Refer to the [documentation](https://table2ascii.readthedocs.io/en/stable/api.html#table2ascii) for more information.
261
265
 
262
- | Option | Type | Default | Description |
263
- | :-----------------: | :----------------------------: | :-------------------: | :-------------------------------------------------------------------------------: |
264
- | `header` | `Sequence[SupportsStr]` | `None` | First table row seperated by header row separator. Values should support `str()` |
265
- | `body` | `Sequence[Sequence[Sequence]]` | `None` | 2D List of rows for the main section of the table. Values should support `str()` |
266
- | `footer` | `Sequence[Sequence]` | `None` | Last table row seperated by header row separator. Values should support `str()` |
267
- | `column_widths` | `Sequence[Optional[int]]` | `None` (automatic) | List of column widths in characters for each column |
268
- | `alignments` | `Sequence[Alignment]` | `None` (all centered) | Column alignments<br/>(ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`) |
269
- | `style` | `TableStyle` | `double_thin_compact` | Table style to use for the table\* |
270
- | `first_col_heading` | `bool` | `False` | Whether to add a heading column separator after the first column |
271
- | `last_col_heading` | `bool` | `False` | Whether to add a heading column separator before the last column |
272
- | `cell_padding` | `int` | `1` | The minimum number of spaces to add between the cell content and the cell border |
273
- | `use_wcwidth` | `bool` | `True` | Whether to use [wcwidth][wcwidth] instead of `len()` to calculate cell width |
266
+ | Option | Supported Types | Description |
267
+ | :-----------------: | :-----------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------: |
268
+ | `header` | `Sequence[SupportsStr]`, `None`<br/>(Default: `None`) | First table row seperated by header row separator. Values should support `str()` |
269
+ | `body` | `Sequence[Sequence[SupportsStr]]`, `None`<br/>(Default: `None`) | 2D List of rows for the main section of the table. Values should support `str()` |
270
+ | `footer` | `Sequence[SupportsStr]`, `None`<br/>(Default: `None`) | Last table row seperated by header row separator. Values should support `str()` |
271
+ | `column_widths` | `Sequence[Optional[int]]`, `None`<br/>(Default: `None` / automatic) | List of column widths in characters for each column |
272
+ | `alignments` | `Sequence[Alignment]`, `Alignment`, `None`<br/>(Default: `None` / all centered) | Column alignments<br/>(ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.DECIMAL]`) |
273
+ | `number_alignments` | `Sequence[Alignment]`, `Alignment`, `None`<br/>(Default: `None`) | Column alignments for numeric values. `alignments` will be used if not specified. |
274
+ | `style` | `TableStyle`<br/>(Default: `double_thin_compact`) | Table style to use for the table\* |
275
+ | `first_col_heading` | `bool`<br/>(Default: `False`) | Whether to add a heading column separator after the first column |
276
+ | `last_col_heading` | `bool`<br/>(Default: `False`) | Whether to add a heading column separator before the last column |
277
+ | `cell_padding` | `int`<br/>(Default: `1`) | The minimum number of spaces to add between the cell content and the cell border |
278
+ | `use_wcwidth` | `bool`<br/>(Default: `True`) | Whether to use [wcwidth][wcwidth] instead of `len()` to calculate cell width |
274
279
 
275
280
  [wcwidth]: https://pypi.org/project/wcwidth/
276
281
 
@@ -69,22 +69,26 @@ print(output)
69
69
  from table2ascii import table2ascii, Alignment
70
70
 
71
71
  output = table2ascii(
72
- header=["#", "G", "H", "R", "S"],
73
- body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
74
- first_col_heading=True,
75
- column_widths=[5, 5, 5, 5, 5],
76
- alignments=[Alignment.LEFT] + [Alignment.RIGHT] * 4,
72
+ header=["Product", "Category", "Price", "Rating"],
73
+ body=[
74
+ ["Milk", "Dairy", "$2.99", "6.283"],
75
+ ["Cheese", "Dairy", "$10.99", "8.2"],
76
+ ["Apples", "Produce", "$0.99", "10.00"],
77
+ ],
78
+ column_widths=[12, 12, 12, 12],
79
+ alignments=[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.DECIMAL],
77
80
  )
78
81
 
79
82
  print(output)
80
83
 
81
84
  """
82
- ╔═════╦═══════════════════════╗
83
- # G H R S ║
84
- ╟─────╫───────────────────────╢
85
- 1 30 40 35 30 ║
86
- ║ 2 30 40 35 30 ║
87
- ╚═════╩═══════════════════════╝
85
+ ╔═══════════════════════════════════════════════════╗
86
+ Product Category Price Rating
87
+ ╟───────────────────────────────────────────────────╢
88
+ Milk Dairy $2.99 6.283
89
+ Cheese Dairy $10.99 8.2
90
+ ║ Apples Produce $0.99 10.00 ║
91
+ ╚═══════════════════════════════════════════════════╝
88
92
  """
89
93
  ```
90
94
 
@@ -119,7 +123,7 @@ output = table2ascii(
119
123
  body=[["10", "30", "40", "35"], ["20", "10", "20", "5"]],
120
124
  style=PresetStyle.plain,
121
125
  cell_padding=0,
122
- alignments=[Alignment.LEFT] * 4,
126
+ alignments=Alignment.LEFT,
123
127
  )
124
128
 
125
129
  print(output)
@@ -199,18 +203,19 @@ All parameters are optional. At least one of `header`, `body`, and `footer` must
199
203
 
200
204
  Refer to the [documentation](https://table2ascii.readthedocs.io/en/stable/api.html#table2ascii) for more information.
201
205
 
202
- | Option | Type | Default | Description |
203
- | :-----------------: | :----------------------------: | :-------------------: | :-------------------------------------------------------------------------------: |
204
- | `header` | `Sequence[SupportsStr]` | `None` | First table row seperated by header row separator. Values should support `str()` |
205
- | `body` | `Sequence[Sequence[Sequence]]` | `None` | 2D List of rows for the main section of the table. Values should support `str()` |
206
- | `footer` | `Sequence[Sequence]` | `None` | Last table row seperated by header row separator. Values should support `str()` |
207
- | `column_widths` | `Sequence[Optional[int]]` | `None` (automatic) | List of column widths in characters for each column |
208
- | `alignments` | `Sequence[Alignment]` | `None` (all centered) | Column alignments<br/>(ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`) |
209
- | `style` | `TableStyle` | `double_thin_compact` | Table style to use for the table\* |
210
- | `first_col_heading` | `bool` | `False` | Whether to add a heading column separator after the first column |
211
- | `last_col_heading` | `bool` | `False` | Whether to add a heading column separator before the last column |
212
- | `cell_padding` | `int` | `1` | The minimum number of spaces to add between the cell content and the cell border |
213
- | `use_wcwidth` | `bool` | `True` | Whether to use [wcwidth][wcwidth] instead of `len()` to calculate cell width |
206
+ | Option | Supported Types | Description |
207
+ | :-----------------: | :-----------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------: |
208
+ | `header` | `Sequence[SupportsStr]`, `None`<br/>(Default: `None`) | First table row seperated by header row separator. Values should support `str()` |
209
+ | `body` | `Sequence[Sequence[SupportsStr]]`, `None`<br/>(Default: `None`) | 2D List of rows for the main section of the table. Values should support `str()` |
210
+ | `footer` | `Sequence[SupportsStr]`, `None`<br/>(Default: `None`) | Last table row seperated by header row separator. Values should support `str()` |
211
+ | `column_widths` | `Sequence[Optional[int]]`, `None`<br/>(Default: `None` / automatic) | List of column widths in characters for each column |
212
+ | `alignments` | `Sequence[Alignment]`, `Alignment`, `None`<br/>(Default: `None` / all centered) | Column alignments<br/>(ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.DECIMAL]`) |
213
+ | `number_alignments` | `Sequence[Alignment]`, `Alignment`, `None`<br/>(Default: `None`) | Column alignments for numeric values. `alignments` will be used if not specified. |
214
+ | `style` | `TableStyle`<br/>(Default: `double_thin_compact`) | Table style to use for the table\* |
215
+ | `first_col_heading` | `bool`<br/>(Default: `False`) | Whether to add a heading column separator after the first column |
216
+ | `last_col_heading` | `bool`<br/>(Default: `False`) | Whether to add a heading column separator before the last column |
217
+ | `cell_padding` | `int`<br/>(Default: `1`) | The minimum number of spaces to add between the cell content and the cell border |
218
+ | `use_wcwidth` | `bool`<br/>(Default: `True`) | Whether to use [wcwidth][wcwidth] instead of `len()` to calculate cell width |
214
219
 
215
220
  [wcwidth]: https://pypi.org/project/wcwidth/
216
221
 
@@ -5,8 +5,8 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "table2ascii"
8
+ version = "1.1.1"
8
9
  authors = [{name = "Jonah Lawrence", email = "jonah@freshidea.com"}]
9
- dynamic = ["version"]
10
10
  description = "Convert 2D Python lists into Unicode/ASCII tables"
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.7"
@@ -39,6 +39,7 @@ classifiers = [
39
39
  ]
40
40
  dependencies = [
41
41
  "typing-extensions>=3.7.4; python_version<'3.8'",
42
+ "importlib-metadata<5,>=1; python_version<'3.8'",
42
43
  "wcwidth<1",
43
44
  ]
44
45
 
@@ -53,8 +54,8 @@ docs = [
53
54
  "sphinx-book-theme==0.3.3",
54
55
  ]
55
56
  dev = [
56
- "mypy>=0.982,<1",
57
- "pre-commit>=2.0.0,<3",
57
+ "mypy>=0.982,<2",
58
+ "pre-commit>=2.0.0,<4",
58
59
  "pyright>=1.0.0,<2",
59
60
  "pytest>=6.0.0,<8",
60
61
  "slotscheck>=0.1.0,<1",
@@ -0,0 +1,7 @@
1
+ # /usr/bin/env python
2
+ from setuptools import setup
3
+
4
+ setup(
5
+ packages=["table2ascii"],
6
+ package_data={"table2ascii": ["py.typed"]},
7
+ )
@@ -0,0 +1,56 @@
1
+ """
2
+ table2ascii - Library for converting 2D Python lists to fancy ASCII/Unicode tables
3
+ """
4
+ import sys
5
+ from typing import TYPE_CHECKING
6
+
7
+ from .alignment import Alignment
8
+ from .annotations import SupportsStr
9
+ from .exceptions import (
10
+ AlignmentCountMismatchError,
11
+ BodyColumnCountMismatchError,
12
+ ColumnCountMismatchError,
13
+ ColumnWidthsCountMismatchError,
14
+ ColumnWidthTooSmallError,
15
+ FooterColumnCountMismatchError,
16
+ InvalidAlignmentError,
17
+ InvalidCellPaddingError,
18
+ InvalidColumnWidthError,
19
+ Table2AsciiError,
20
+ TableOptionError,
21
+ TableStyleTooLongError,
22
+ TableStyleTooShortWarning,
23
+ )
24
+ from .merge import Merge
25
+ from .preset_style import PresetStyle
26
+ from .table_style import TableStyle
27
+ from .table_to_ascii import table2ascii
28
+
29
+ if TYPE_CHECKING or sys.version_info >= (3, 8):
30
+ from importlib import metadata
31
+ else:
32
+ import importlib_metadata as metadata
33
+
34
+ __version__ = metadata.version(__name__)
35
+
36
+ __all__ = [
37
+ "Alignment",
38
+ "Merge",
39
+ "PresetStyle",
40
+ "TableStyle",
41
+ "table2ascii",
42
+ "AlignmentCountMismatchError",
43
+ "BodyColumnCountMismatchError",
44
+ "ColumnCountMismatchError",
45
+ "ColumnWidthsCountMismatchError",
46
+ "ColumnWidthTooSmallError",
47
+ "FooterColumnCountMismatchError",
48
+ "InvalidAlignmentError",
49
+ "InvalidCellPaddingError",
50
+ "InvalidColumnWidthError",
51
+ "Table2AsciiError",
52
+ "TableOptionError",
53
+ "TableStyleTooLongError",
54
+ "TableStyleTooShortWarning",
55
+ "SupportsStr",
56
+ ]
@@ -0,0 +1,73 @@
1
+ from enum import IntEnum
2
+
3
+
4
+ class Alignment(IntEnum):
5
+ """Enum for text alignment types within a table cell
6
+
7
+ A list of alignment types can be used to align each column individually::
8
+
9
+ from table2ascii import Alignment, table2ascii
10
+
11
+ table2ascii(
12
+ header=["Product", "Category", "Price", "Rating"],
13
+ body=[
14
+ ["Milk", "Dairy", "$2.99", "6.28318"],
15
+ ["Cheese", "Dairy", "$10.99", "8.2"],
16
+ ["Apples", "Produce", "$0.99", "10.00"],
17
+ ],
18
+ # Align the first column to the left, the second to the center,
19
+ # the third to the right, and the fourth to the decimal point
20
+ alignments=[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT, Alignment.DECIMAL],
21
+ )
22
+
23
+ \"\"\"
24
+ ╔════════════════════════════════════════╗
25
+ ║ Product Category Price Rating ║
26
+ ╟────────────────────────────────────────╢
27
+ ║ Milk Dairy $2.99 6.28318 ║
28
+ ║ Cheese Dairy $10.99 8.2 ║
29
+ ║ Apples Produce $0.99 10.00 ║
30
+ ╚════════════════════════════════════════╝
31
+ \"\"\"
32
+
33
+ A single alignment type can be used to align all columns::
34
+
35
+ table2ascii(
36
+ header=["First Name", "Last Name", "Age"],
37
+ body=[
38
+ ["John", "Smith", 30],
39
+ ["Jane", "Doe", 28],
40
+ ],
41
+ alignments=Alignment.LEFT, # Align all columns to the left
42
+ number_alignments=Alignment.RIGHT, # Align all numeric values to the right
43
+ )
44
+
45
+ \"\"\"
46
+ ╔══════════════════════════════╗
47
+ ║ First Name Last Name Age ║
48
+ ╟──────────────────────────────╢
49
+ ║ John Smith 30 ║
50
+ ║ Jane Doe 28 ║
51
+ ╚══════════════════════════════╝
52
+ \"\"\"
53
+
54
+ .. note::
55
+
56
+ If :attr:`DECIMAL` is used in the ``number_alignments`` argument to :func:`table2ascii`,
57
+ all non-numeric values will be aligned according to the ``alignments`` argument.
58
+ If the :attr:`DECIMAL` alignment type is used in the ``alignments`` argument,
59
+ all non-numeric values will be aligned to the center.
60
+ Numeric values include integers, floats, and strings containing only :meth:`decimal <str.isdecimal>`
61
+ characters and at most one decimal point.
62
+
63
+ .. versionchanged:: 1.1.0
64
+
65
+ Added :attr:`DECIMAL` alignment -- align decimal numbers such that
66
+ the decimal point is aligned with the decimal point of all other numbers
67
+ in the same column.
68
+ """
69
+
70
+ LEFT = 0
71
+ CENTER = 1
72
+ RIGHT = 2
73
+ DECIMAL = 3
@@ -2,19 +2,17 @@ import sys
2
2
  from abc import abstractmethod
3
3
  from typing import TYPE_CHECKING
4
4
 
5
- if sys.version_info >= (3, 8):
5
+ if TYPE_CHECKING or sys.version_info >= (3, 8):
6
6
  from typing import Protocol, runtime_checkable
7
7
  else:
8
8
  from typing_extensions import Protocol, runtime_checkable
9
9
 
10
- if TYPE_CHECKING:
11
- from typing import Protocol
12
-
13
10
 
14
11
  @runtime_checkable
15
12
  class SupportsStr(Protocol):
16
- """An ABC with one abstract method __str__."""
13
+ """An abstract base class (ABC) with one abstract method :meth:`__str__`"""
17
14
 
18
15
  @abstractmethod
19
16
  def __str__(self) -> str:
17
+ """Return a string representation of the object"""
20
18
  pass
@@ -40,8 +40,9 @@ class FooterColumnCountMismatchError(ColumnCountMismatchError):
40
40
  This class is a subclass of :class:`ColumnCountMismatchError`.
41
41
 
42
42
  Attributes:
43
- footer (Sequence[SupportsStr]): The footer that caused the error
44
- expected_columns (int): The number of columns that were expected
43
+ footer (:class:`Sequence <collections.abc.Sequence>`\ [:class:`SupportsStr`]):
44
+ The footer that caused the error
45
+ expected_columns (:class:`int`): The number of columns that were expected
45
46
  """
46
47
 
47
48
  def __init__(self, footer: Sequence[SupportsStr], expected_columns: int):
@@ -63,9 +64,11 @@ class BodyColumnCountMismatchError(ColumnCountMismatchError):
63
64
  This class is a subclass of :class:`ColumnCountMismatchError`.
64
65
 
65
66
  Attributes:
66
- body (Sequence[Sequence[SupportsStr]]): The body that caused the error
67
- expected_columns (int): The number of columns that were expected
68
- first_invalid_row (Sequence[SupportsStr]): The first row with an invalid column count
67
+ body (:class:`Sequence <collections.abc.Sequence>`\ [\ :class:`Sequence <collections.abc.Sequence>`\ [:class:`SupportsStr`]]):
68
+ The body that caused the error
69
+ expected_columns (:class:`int`): The number of columns that were expected
70
+ first_invalid_row (:class:`Sequence <collections.abc.Sequence>`\ [:class:`SupportsStr`]):
71
+ The first row with an invalid column count
69
72
  """
70
73
 
71
74
  def __init__(self, body: Sequence[Sequence[SupportsStr]], expected_columns: int):
@@ -90,8 +93,9 @@ class AlignmentCountMismatchError(ColumnCountMismatchError):
90
93
  This class is a subclass of :class:`ColumnCountMismatchError`.
91
94
 
92
95
  Attributes:
93
- alignments (Sequence[Alignment]): The alignments that caused the error
94
- expected_columns (int): The number of columns that were expected
96
+ alignments (:class:`Sequence <collections.abc.Sequence>`\ [:class:`Alignment`]):
97
+ The alignments that caused the error
98
+ expected_columns (:class:`int`): The number of columns that were expected
95
99
  """
96
100
 
97
101
  def __init__(self, alignments: Sequence[Alignment], expected_columns: int):
@@ -113,8 +117,9 @@ class ColumnWidthsCountMismatchError(ColumnCountMismatchError):
113
117
  This class is a subclass of :class:`ColumnCountMismatchError`.
114
118
 
115
119
  Attributes:
116
- column_widths (Sequence[Optional[int]]): The column widths that caused the error
117
- expected_columns (int): The number of columns that were expected
120
+ column_widths (:class:`Sequence <collections.abc.Sequence>`\ [:data:`Optional <typing.Optional>`\ [:class:`int`]]):
121
+ The column widths that caused the error
122
+ expected_columns (:class:`int`): The number of columns that were expected
118
123
  """
119
124
 
120
125
  def __init__(self, column_widths: Sequence[int | None], expected_columns: int):
@@ -148,7 +153,7 @@ class InvalidCellPaddingError(TableOptionError):
148
153
  This class is a subclass of :class:`TableOptionError`.
149
154
 
150
155
  Attributes:
151
- padding (int): The padding that caused the error
156
+ padding (:class:`int`): The padding that caused the error
152
157
  """
153
158
 
154
159
  def __init__(self, padding: int):
@@ -169,9 +174,9 @@ class ColumnWidthTooSmallError(TableOptionError):
169
174
  This class is a subclass of :class:`TableOptionError`.
170
175
 
171
176
  Attributes:
172
- column_index (int): The index of the column that caused the error
173
- column_width (int): The column width that caused the error
174
- min_width (int): The minimum width that is allowed
177
+ column_index (:class:`int`): The index of the column that caused the error
178
+ column_width (:class:`int`): The column width that caused the error
179
+ min_width (:class:`int`): The minimum width that is allowed
175
180
  """
176
181
 
177
182
  def __init__(self, column_index: int, column_width: int, min_width: int | None = None):
@@ -208,7 +213,7 @@ class InvalidAlignmentError(TableOptionError):
208
213
  This class is a subclass of :class:`TableOptionError`.
209
214
 
210
215
  Attributes:
211
- alignment (Any): The alignment value that caused the error
216
+ alignment (:data:`Any <typing.Any>`): The alignment value that caused the error
212
217
  """
213
218
 
214
219
  def __init__(self, alignment: Any):
@@ -230,8 +235,8 @@ class TableStyleTooLongError(Table2AsciiError, ValueError):
230
235
  This class is a subclass of :class:`Table2AsciiError` and :class:`ValueError`.
231
236
 
232
237
  Attributes:
233
- string (str): The string that caused the error
234
- max_characters (int): The maximum number of characters that are allowed
238
+ string (:class:`str`): The string that caused the error
239
+ max_characters (:class:`int`): The maximum number of characters that are allowed
235
240
  """
236
241
 
237
242
  def __init__(self, string: str, max_characters: int):
@@ -256,8 +261,8 @@ class TableStyleTooShortWarning(UserWarning):
256
261
  It can be silenced using :func:`warnings.filterwarnings`.
257
262
 
258
263
  Attributes:
259
- string (str): The string that caused the warning
260
- max_characters (int): The number of characters that :class:`TableStyle` accepts
264
+ string (:class:`str`): The string that caused the warning
265
+ max_characters (:class:`int`): The number of characters that :class:`TableStyle` accepts
261
266
  """
262
267
 
263
268
  def __init__(self, string: str, max_characters: int):
@@ -11,6 +11,10 @@ from .table_style import TableStyle
11
11
  class Options:
12
12
  """Class for storing options that the user sets
13
13
 
14
+ .. versionchanged:: 1.1.0
15
+
16
+ Added ``number_alignments`` option
17
+
14
18
  .. versionchanged:: 1.0.0
15
19
 
16
20
  Added ``use_wcwidth`` option
@@ -19,7 +23,8 @@ class Options:
19
23
  first_col_heading: bool
20
24
  last_col_heading: bool
21
25
  column_widths: Sequence[int | None] | None
22
- alignments: Sequence[Alignment] | None
26
+ alignments: Sequence[Alignment] | Alignment | None
27
+ number_alignments: Sequence[Alignment] | Alignment | None
23
28
  cell_padding: int
24
29
  style: TableStyle
25
30
  use_wcwidth: bool
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561. The table2ascii package uses inline types.
@@ -145,7 +145,7 @@ class TableStyle:
145
145
 
146
146
  Example::
147
147
 
148
- TableStyle().set(top_left_corner="", top_and_bottom_edge="")
148
+ TableStyle.from_string("~" * 30).set(left_and_right_edge="", col_sep="")
149
149
  """
150
150
  for key, value in kwargs.items():
151
151
  setattr(self, key, value)