Skip to content

Commit 9c27240

Browse files
authored
refactor: New annotation style and dependency specificity (#61)
1 parent 3326402 commit 9c27240

11 files changed

+48
-42
lines changed

Diff for: .github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
setup.py
5050
5151
- name: Install dependencies
52-
run: python -m pip install -r requirements.txt -e ".[dev]" -e ".[docs]"
52+
run: python -m pip install -r requirements.txt -e ".[dev]"
5353

5454
- name: Set up pyright
5555
run: echo "PYRIGHT_VERSION=$(python -c 'import pyright; print(pyright.__pyright_version__)')" >> $GITHUB_ENV
@@ -80,7 +80,7 @@ jobs:
8080
runs-on: ubuntu-latest
8181
strategy:
8282
matrix:
83-
python-version: ["3.10"]
83+
python-version: ["3.11"]
8484
steps:
8585
- name: Checkout code
8686
uses: actions/checkout@v3

Diff for: .github/workflows/python-publish.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
deploy:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717
- name: Set up Python
18-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v4
1919
with:
20-
python-version: '3.10'
20+
python-version: '3.11'
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip

Diff for: .github/workflows/python-test.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ jobs:
1616
build:
1717
runs-on: ubuntu-latest
1818

19+
strategy:
20+
matrix:
21+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1922
steps:
20-
- uses: actions/checkout@v2
21-
- name: Set up Python 3.7
22-
uses: actions/setup-python@v2
23+
- uses: actions/checkout@v3
24+
- name: Set up Python
25+
uses: actions/setup-python@v4
2326
with:
24-
python-version: 3.7
27+
python-version: ${{ matrix.python-version }}
2528
- name: Install dependencies
2629
run: |
2730
python -m pip install --upgrade pip
28-
pip install flake8==3.8.4 pytest tox
29-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
python -m pip install -r requirements.txt -e ".[dev]"
3032
- name: Test with pytest
3133
run: |
32-
tox
34+
# remove '.' in python-version and prepend with 'py' to get the correct tox env
35+
tox -e py$(echo ${{ matrix.python-version }} | sed 's/\.//g')

Diff for: .github/workflows/python-update-docs.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ['3.10']
17+
python-version: ['3.11']
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v4
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
- name: Install dependencies
@@ -28,7 +28,7 @@ jobs:
2828
- name: execute script
2929
run: |
3030
python ./docs/source/generate_style_list.py
31-
- uses: EndBug/add-and-commit@v8
31+
- uses: EndBug/add-and-commit@v9
3232
with:
3333
default_author: github_actions
3434
message: 'docs: update style list'

Diff for: .github/workflows/test-docs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ['3.7']
17+
python-version: ['3.11']
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v4
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
- name: Install dependencies

Diff for: pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ lint = { cmd = "pre-commit run --all-files", help = "Check all files for linting
3333
precommit = { cmd = "pre-commit install --install-hooks", help = "Install the precommit hook" }
3434
pyright = { cmd = "pyright", help = "Run pyright" }
3535
slotscheck = { cmd = "python -m slotscheck --verbose -m table2ascii", help = "Run slotscheck" }
36-
test = { cmd = "tox", help = "Run tests" }
36+
test = { cmd = "tox --skip-missing-interpreters", help = "Run tests" }
3737

3838

3939
[tool.slotscheck]
@@ -70,7 +70,7 @@ reportUnnecessaryTypeIgnoreComment = true
7070

7171

7272
[tool.mypy]
73-
python_version = "3.10"
73+
python_version = "3.11"
7474
namespace_packages = true
7575

7676

Diff for: requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
typing_extensions>=4.0.0,<5
1+
typing-extensions>=3.7.4; python_version<'3.8'

Diff for: setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import re
44

55
from setuptools import setup
6-
from setuptools.command.test import test as Command
76

87

98
def version():
@@ -76,7 +75,7 @@ def requirements():
7675
],
7776
keywords="table ascii unicode formatter",
7877
python_requires=">=3.6",
79-
install_requires=[requirements()],
78+
install_requires=requirements(),
8079
extras_require=extras_require,
8180
setup_requires=[
8281
"flake8>=3.8,<4",

Diff for: table2ascii/options.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from __future__ import annotations
2+
13
from dataclasses import dataclass
2-
from typing import List, Optional
34

45
from .alignment import Alignment
56
from .table_style import TableStyle
@@ -11,7 +12,7 @@ class Options:
1112

1213
first_col_heading: bool
1314
last_col_heading: bool
14-
column_widths: Optional[List[Optional[int]]]
15-
alignments: Optional[List[Alignment]]
15+
column_widths: list[int | None] | None
16+
alignments: list[Alignment] | None
1617
cell_padding: int
1718
style: TableStyle

Diff for: table2ascii/table_to_ascii.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from __future__ import annotations
2+
13
from math import ceil, floor
2-
from typing import Callable, List, Optional, Union
34

45
from .alignment import Alignment
56
from .annotations import SupportsStr
@@ -13,9 +14,9 @@ class TableToAscii:
1314

1415
def __init__(
1516
self,
16-
header: Optional[List[SupportsStr]],
17-
body: Optional[List[List[SupportsStr]]],
18-
footer: Optional[List[SupportsStr]],
17+
header: list[SupportsStr] | None,
18+
body: list[list[SupportsStr]] | None,
19+
footer: list[SupportsStr] | None,
1920
options: Options,
2021
):
2122
"""
@@ -92,7 +93,7 @@ def __count_columns(self) -> int:
9293
return len(self.__body[0])
9394
return 0
9495

95-
def __auto_column_widths(self) -> List[int]:
96+
def __auto_column_widths(self) -> list[int]:
9697
"""
9798
Get the minimum number of characters needed for the values in
9899
each column in the table with 1 space of padding on each side.
@@ -151,7 +152,7 @@ def __row_to_ascii(
151152
heading_col_sep: str,
152153
column_seperator: str,
153154
right_edge: str,
154-
filler: Union[str, List],
155+
filler: str | list[SupportsStr],
155156
) -> str:
156157
"""
157158
Assembles a line of text in the ascii table
@@ -235,7 +236,7 @@ def __bottom_edge_to_ascii(self) -> str:
235236
filler=self.__style.top_and_bottom_edge,
236237
)
237238

238-
def __heading_row_to_ascii(self, row: List) -> str:
239+
def __heading_row_to_ascii(self, row: list[SupportsStr]) -> str:
239240
"""
240241
Assembles the header or footer row line of the ascii table
241242
@@ -265,7 +266,7 @@ def __heading_sep_to_ascii(self) -> str:
265266
filler=self.__style.heading_row_sep,
266267
)
267268

268-
def __body_to_ascii(self, body: List[List[SupportsStr]]) -> str:
269+
def __body_to_ascii(self, body: list[list[SupportsStr]]) -> str:
269270
"""
270271
Assembles the body of the ascii table
271272
@@ -317,14 +318,14 @@ def to_ascii(self) -> str:
317318

318319

319320
def table2ascii(
320-
header: Optional[List[SupportsStr]] = None,
321-
body: Optional[List[List[SupportsStr]]] = None,
322-
footer: Optional[List[SupportsStr]] = None,
321+
header: list[SupportsStr] | None = None,
322+
body: list[list[SupportsStr]] | None = None,
323+
footer: list[SupportsStr] | None = None,
323324
*,
324325
first_col_heading: bool = False,
325326
last_col_heading: bool = False,
326-
column_widths: Optional[List[Optional[int]]] = None,
327-
alignments: Optional[List[Alignment]] = None,
327+
column_widths: list[int | None] | None = None,
328+
alignments: list[Alignment] | None = None,
328329
cell_padding: int = 1,
329330
style: TableStyle = PresetStyle.double_thin_compact,
330331
) -> str:

Diff for: tox.ini

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[tox]
2-
envlist = python3.9
2+
envlist = py37, py38, py39, py310, py311
33

44
[testenv]
5-
deps = pytest
5+
deps =
6+
pytest
7+
-rrequirements.txt
68
commands = pytest tests -s

0 commit comments

Comments
 (0)