diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..91b025b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,69 @@ +## Contributing Guidelines + +Contributions are welcome! Feel free to open an issue or submit a pull request if you have a way to improve this project. + +Make sure your request is meaningful and you have tested the app locally before submitting a pull request. + +### Installing Requirements + +#### Software Requirements + +- [Python 3.7+](https://www.python.org/downloads/) + +#### Development Dependencies + +Install development dependencies with: + +```bash +pip install -e ".[dev]" +``` + +Install documentation dependencies with: + +```bash +pip install -e ".[docs]" +``` + +### Running the Tests + +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. + +```bash +task test +``` + +### Linting + +Black, isort, and pre-commit hooks are used to lint the codebase. Run the following command to lint and fix the codebase. + +```bash +task lint +``` + +### Pyright + +To ensure that type hints are used correctly, Pyright is used to lint the codebase. Run the following command to check for typing errors. + +```bash +task pyright +``` + +### Documentation + +To view the documentation locally, run the following command. + +```bash +task docs +``` + +The documentation will be served at . + +### Need some help regarding the basics? + +You can refer to the following articles on the basics of Git and GitHub in case you are stuck: + +- [Forking a Repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) +- [Cloning a Repo](https://help.github.com/en/desktop/contributing-to-projects/creating-an-issue-or-pull-request) +- [How to create a Pull Request](https://opensource.com/article/19/7/create-pull-request-github) +- [Getting started with Git and GitHub](https://towardsdatascience.com/getting-started-with-git-and-github-6fcd0f2d4ac6) +- [Learn GitHub from Scratch](https://lab.github.com/githubtraining/introduction-to-github) \ No newline at end of file diff --git a/README.md b/README.md index 5a1da1d..e6ec014 100644 --- a/README.md +++ b/README.md @@ -176,14 +176,8 @@ All parameters are optional. ![image](https://user-images.githubusercontent.com/20955511/116204490-802dcf80-a745-11eb-9b4a-7cef49f23958.png) -## 🧰 Development +## 🤗 Contributing -Install development dependencies with `pip install -e .[dev]` +Contributions are welcome! -### Running tests - -Run tests with the command `tox` - -### Linting - -Run `task lint` to lint with black, isort, and pre-commit hooks. +See [CONTRIBUTING.md](https://github.com/DenverCoder1/table2ascii/blob/main/CONTRIBUTING.md) for more details on how to get involved. diff --git a/pyproject.toml b/pyproject.toml index e529124..c79dcf3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,8 +31,9 @@ docs = { cmd = "cd docs && sphinx-autobuild source _build/html --ignore _build - isort = { cmd = "task lint isort", help = "Run isort" } lint = { cmd = "pre-commit run --all-files", help = "Check all files for linting errors" } precommit = { cmd = "pre-commit install --install-hooks", help = "Install the precommit hook" } -pyright = { cmd = "dotenv -f task.env run -- pyright", help = "Run pyright" } +pyright = { cmd = "pyright", help = "Run pyright" } slotscheck = { cmd = "python -m slotscheck --verbose -m table2ascii", help = "Run slotscheck" } +test = { cmd = "tox", help = "Run tests" } [tool.slotscheck] @@ -45,6 +46,7 @@ require-subclass = false typeCheckingMode = "basic" include = [ "table2ascii", + "tests", "*.py", ] pythonVersion = "3.7" diff --git a/setup.py b/setup.py index 66a8e5d..c4f622c 100644 --- a/setup.py +++ b/setup.py @@ -45,9 +45,9 @@ def requirements(): "pre-commit==2.18.1", "taskipy==1.10.1", "slotscheck==0.14.0", - "python-dotenv==0.20.0", "pyright==1.1.244", "tox==3.24.5", + "pytest==7.1.2", ], } diff --git a/table2ascii/table_to_ascii.py b/table2ascii/table_to_ascii.py index b344b81..3f77d89 100644 --- a/table2ascii/table_to_ascii.py +++ b/table2ascii/table_to_ascii.py @@ -327,7 +327,7 @@ def table2ascii( footer (:class:`Optional[List[Any]]`): List of column values in the table's footer row first_col_heading (:class:`bool`): Whether to add a header column separator after the first column last_col_heading (:class:`bool`): Whether to add a header column separator before the last column - column_widths (:class:`List[int]`): List of widths in characters for each column (defaults to auto-sizing) + column_widths (:class:`Optional[List[int]]`): List of widths in characters for each column (``None`` for auto-sizing) alignments (:class:`List[Alignment]`): List of alignments (ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`) style (:class:`TableStyle`): Table style to use for styling (preset styles can be imported) diff --git a/task.env b/task.env deleted file mode 100644 index b0e60a2..0000000 --- a/task.env +++ /dev/null @@ -1 +0,0 @@ -PYRIGHT_PYTHON_IGNORE_WARNINGS=1 \ No newline at end of file diff --git a/tests/test_alignments.py b/tests/test_alignments.py index 555f0b6..b0c18b2 100644 --- a/tests/test_alignments.py +++ b/tests/test_alignments.py @@ -1,6 +1,6 @@ import pytest -from table2ascii import Alignment, alignment, table2ascii as t2a +from table2ascii import Alignment, table2ascii as t2a def test_first_left_four_right(): @@ -42,7 +42,7 @@ def test_invalid_alignments(): body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]], footer=["SUM", "130", "140", "135", "130"], first_col_heading=True, - alignments=[9999, -1, Alignment.RIGHT, Alignment.CENTER, Alignment.RIGHT], + alignments=[9999, -1, Alignment.RIGHT, Alignment.CENTER, Alignment.RIGHT], # type: ignore ) diff --git a/tests/test_column_widths.py b/tests/test_column_widths.py index feecfc0..f7b367d 100644 --- a/tests/test_column_widths.py +++ b/tests/test_column_widths.py @@ -25,6 +25,28 @@ def test_column_widths(): assert text == expected +def test_column_widths_none(): + text = t2a( + header=["#", "G", "H", "R", "S"], + body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]], + footer=["TOTL", "130", "140", "135", "130"], + first_col_heading=True, + last_col_heading=True, + column_widths=None, + ) + expected = ( + "╔══════╦═════════════════╦═════╗\n" + "║ # ║ G H R ║ S ║\n" + "╟──────╫─────────────────╫─────╢\n" + "║ 1 ║ 30 40 35 ║ 30 ║\n" + "║ 2 ║ 30 40 35 ║ 30 ║\n" + "╟──────╫─────────────────╫─────╢\n" + "║ TOTL ║ 130 140 135 ║ 130 ║\n" + "╚══════╩═════════════════╩═════╝" + ) + assert text == expected + + def test_wrong_number_column_widths(): with pytest.raises(ValueError): t2a( diff --git a/tests/test_convert.py b/tests/test_convert.py index cb67a03..5c0653a 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -1,6 +1,6 @@ import pytest -from table2ascii import alignment, table2ascii as t2a +from table2ascii import table2ascii as t2a def test_header_body_footer():