Skip to content

Commit edc2c67

Browse files
authored
ci,docs: Add Pyright checks to tests, add contributing docs (#37)
* docs: Updated docs and added col width test * ci: Remove ignore warnings, add pytest as a dev dep * pyright on tests, remove unused imports * Add test task * Add CONTRIBUTING.md and update docs
1 parent 33c600b commit edc2c67

File tree

9 files changed

+102
-16
lines changed

9 files changed

+102
-16
lines changed

CONTRIBUTING.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
## Contributing Guidelines
2+
3+
Contributions are welcome! Feel free to open an issue or submit a pull request if you have a way to improve this project.
4+
5+
Make sure your request is meaningful and you have tested the app locally before submitting a pull request.
6+
7+
### Installing Requirements
8+
9+
#### Software Requirements
10+
11+
- [Python 3.7+](https://www.python.org/downloads/)
12+
13+
#### Development Dependencies
14+
15+
Install development dependencies with:
16+
17+
```bash
18+
pip install -e ".[dev]"
19+
```
20+
21+
Install documentation dependencies with:
22+
23+
```bash
24+
pip install -e ".[docs]"
25+
```
26+
27+
### Running the Tests
28+
29+
Run the following command to run the [Tox](https://github.com/tox-dev/tox) test script which will verify that the tested functionality is still working.
30+
31+
```bash
32+
task test
33+
```
34+
35+
### Linting
36+
37+
Black, isort, and pre-commit hooks are used to lint the codebase. Run the following command to lint and fix the codebase.
38+
39+
```bash
40+
task lint
41+
```
42+
43+
### Pyright
44+
45+
To ensure that type hints are used correctly, Pyright is used to lint the codebase. Run the following command to check for typing errors.
46+
47+
```bash
48+
task pyright
49+
```
50+
51+
### Documentation
52+
53+
To view the documentation locally, run the following command.
54+
55+
```bash
56+
task docs
57+
```
58+
59+
The documentation will be served at <http://127.0.0.1:8888>.
60+
61+
### Need some help regarding the basics?
62+
63+
You can refer to the following articles on the basics of Git and GitHub in case you are stuck:
64+
65+
- [Forking a Repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
66+
- [Cloning a Repo](https://help.github.com/en/desktop/contributing-to-projects/creating-an-issue-or-pull-request)
67+
- [How to create a Pull Request](https://opensource.com/article/19/7/create-pull-request-github)
68+
- [Getting started with Git and GitHub](https://towardsdatascience.com/getting-started-with-git-and-github-6fcd0f2d4ac6)
69+
- [Learn GitHub from Scratch](https://lab.github.com/githubtraining/introduction-to-github)

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,8 @@ All parameters are optional.
176176
![image](https://user-images.githubusercontent.com/20955511/116204490-802dcf80-a745-11eb-9b4a-7cef49f23958.png)
177177

178178

179-
## 🧰 Development
179+
## 🤗 Contributing
180180

181-
Install development dependencies with `pip install -e .[dev]`
181+
Contributions are welcome!
182182

183-
### Running tests
184-
185-
Run tests with the command `tox`
186-
187-
### Linting
188-
189-
Run `task lint` to lint with black, isort, and pre-commit hooks.
183+
See [CONTRIBUTING.md](https://github.com/DenverCoder1/table2ascii/blob/main/CONTRIBUTING.md) for more details on how to get involved.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ docs = { cmd = "cd docs && sphinx-autobuild source _build/html --ignore _build -
3131
isort = { cmd = "task lint isort", help = "Run isort" }
3232
lint = { cmd = "pre-commit run --all-files", help = "Check all files for linting errors" }
3333
precommit = { cmd = "pre-commit install --install-hooks", help = "Install the precommit hook" }
34-
pyright = { cmd = "dotenv -f task.env run -- pyright", help = "Run pyright" }
34+
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" }
3637

3738

3839
[tool.slotscheck]
@@ -45,6 +46,7 @@ require-subclass = false
4546
typeCheckingMode = "basic"
4647
include = [
4748
"table2ascii",
49+
"tests",
4850
"*.py",
4951
]
5052
pythonVersion = "3.7"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def requirements():
4545
"pre-commit==2.18.1",
4646
"taskipy==1.10.1",
4747
"slotscheck==0.14.0",
48-
"python-dotenv==0.20.0",
4948
"pyright==1.1.244",
5049
"tox==3.24.5",
50+
"pytest==7.1.2",
5151
],
5252
}
5353

table2ascii/table_to_ascii.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def table2ascii(
327327
footer (:class:`Optional[List[Any]]`): List of column values in the table's footer row
328328
first_col_heading (:class:`bool`): Whether to add a header column separator after the first column
329329
last_col_heading (:class:`bool`): Whether to add a header column separator before the last column
330-
column_widths (:class:`List[int]`): List of widths in characters for each column (defaults to auto-sizing)
330+
column_widths (:class:`Optional[List[int]]`): List of widths in characters for each column (``None`` for auto-sizing)
331331
alignments (:class:`List[Alignment]`): List of alignments (ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`)
332332
style (:class:`TableStyle`): Table style to use for styling (preset styles can be imported)
333333

task.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test_alignments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from table2ascii import Alignment, alignment, table2ascii as t2a
3+
from table2ascii import Alignment, table2ascii as t2a
44

55

66
def test_first_left_four_right():
@@ -42,7 +42,7 @@ def test_invalid_alignments():
4242
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
4343
footer=["SUM", "130", "140", "135", "130"],
4444
first_col_heading=True,
45-
alignments=[9999, -1, Alignment.RIGHT, Alignment.CENTER, Alignment.RIGHT],
45+
alignments=[9999, -1, Alignment.RIGHT, Alignment.CENTER, Alignment.RIGHT], # type: ignore
4646
)
4747

4848

tests/test_column_widths.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ def test_column_widths():
2525
assert text == expected
2626

2727

28+
def test_column_widths_none():
29+
text = t2a(
30+
header=["#", "G", "H", "R", "S"],
31+
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
32+
footer=["TOTL", "130", "140", "135", "130"],
33+
first_col_heading=True,
34+
last_col_heading=True,
35+
column_widths=None,
36+
)
37+
expected = (
38+
"╔══════╦═════════════════╦═════╗\n"
39+
"║ # ║ G H R ║ S ║\n"
40+
"╟──────╫─────────────────╫─────╢\n"
41+
"║ 1 ║ 30 40 35 ║ 30 ║\n"
42+
"║ 2 ║ 30 40 35 ║ 30 ║\n"
43+
"╟──────╫─────────────────╫─────╢\n"
44+
"║ TOTL ║ 130 140 135 ║ 130 ║\n"
45+
"╚══════╩═════════════════╩═════╝"
46+
)
47+
assert text == expected
48+
49+
2850
def test_wrong_number_column_widths():
2951
with pytest.raises(ValueError):
3052
t2a(

tests/test_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from table2ascii import alignment, table2ascii as t2a
3+
from table2ascii import table2ascii as t2a
44

55

66
def test_header_body_footer():

0 commit comments

Comments
 (0)