From b4b8465cd1f9c1e9526ffda9c0f6c42a2d09e48c Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Sat, 18 Nov 2023 18:46:37 +0330 Subject: [PATCH 1/6] feat: Makefile added --- Makefile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..50d4e72 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +.DEFAULT_GOAL := help +.PHONY: docs +SRC_DIRS = ./tutorwebui +BLACK_OPTS = --exclude templates ${SRC_DIRS} + +# Warning: These checks are not necessarily run on every PR. +test: test-lint test-types test-format # Run some static checks. + +test-format: ## Run code formatting tests + black --check --diff $(BLACK_OPTS) + +test-lint: ## Run code linting tests + pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS} + +test-types: ## Run type checks. + mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS} + +format: ## Format code automatically + black $(BLACK_OPTS) + +isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes. + isort --skip=templates ${SRC_DIRS} + +changelog-entry: ## Create a new changelog entry. + scriv create + +changelog: ## Collect changelog entries in the CHANGELOG.md file. + scriv collect + +ESCAPE =  +help: ## Print this help + @grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \ + | sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}' From 8551e77ba22c9b538e45323a6e1706e9f994c076 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Sat, 18 Nov 2023 18:46:42 +0330 Subject: [PATCH 2/6] chore: changelog entry added --- changelog.d/20231005_153050_codewithemad.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/20231005_153050_codewithemad.md diff --git a/changelog.d/20231005_153050_codewithemad.md b/changelog.d/20231005_153050_codewithemad.md new file mode 100644 index 0000000..81ca4f1 --- /dev/null +++ b/changelog.d/20231005_153050_codewithemad.md @@ -0,0 +1 @@ +- [Improvement] Added Makefile and test action to repository and formatted code with Black and isort. (by @CodeWithEmad) \ No newline at end of file From 6d8b09912ff148a5e48c9178b09a2a7fefae3cd0 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Sat, 18 Nov 2023 18:47:02 +0330 Subject: [PATCH 3/6] fix: typing added --- tutorwebui/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tutorwebui/cli.py b/tutorwebui/cli.py index 4ee40eb..7c940ee 100644 --- a/tutorwebui/cli.py +++ b/tutorwebui/cli.py @@ -117,7 +117,8 @@ def shell() -> None: # incorrectly calls the `commands` attribute. Note that this enables us to # run shell within shell, which is cool but a little weird... ctx = click.get_current_context() - ctx.parent.command.commands = {} + if ctx.parent and ctx.parent.command: + ctx.parent.command.commands = {} # type: ignore while True: try: From 40b652d8c85ca56570a8e500dcdc09158e4be9a8 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Sat, 18 Nov 2023 18:47:15 +0330 Subject: [PATCH 4/6] chore: cleanup with isort and black --- tutorwebui/__about__.py | 1 - tutorwebui/plugin.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorwebui/__about__.py b/tutorwebui/__about__.py index 1722f39..5e5e910 100644 --- a/tutorwebui/__about__.py +++ b/tutorwebui/__about__.py @@ -1,2 +1 @@ __version__ = "16.0.0" - diff --git a/tutorwebui/plugin.py b/tutorwebui/plugin.py index 7848821..3cf4de5 100644 --- a/tutorwebui/plugin.py +++ b/tutorwebui/plugin.py @@ -1,7 +1,8 @@ from tutor import hooks as tutor_hooks from tutor.__about__ import __version_suffix__ -from .__about__ import __version__ + from . import cli +from .__about__ import __version__ # Handle version suffix in nightly mode, just like tutor core if __version_suffix__: From ba9fb578422a532c8eab3643689476de520252bd Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Fri, 8 Dec 2023 13:43:52 +0330 Subject: [PATCH 5/6] feat: Including dev dependencies in extras_require --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 9271dea..8ed7927 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ def load_about(): include_package_data=True, python_requires=">=3.8", install_requires=["tutor>=16.0.0,<17.0.0", "click_repl>=0.2.0"], + extras_require={"dev": "tutor[dev]>=16.0.0,<17.0.0"}, entry_points={ "tutor.plugin.v1": ["webui = tutorwebui.plugin"], }, From 09b6c5d3a7c670965a311f2571da7525e70c54f6 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Fri, 8 Dec 2023 13:44:29 +0330 Subject: [PATCH 6/6] ci: test action added --- .github/workflows/test.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..829f613 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: Run tests + +on: + pull_request: + branches: [master] + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Upgrade pip + run: python -m pip install --upgrade pip setuptools + - name: Install dependencies + run: | + pip install .[dev] + - name: Test lint, types, and format + run: make test