diff --git a/.github/workflows/build_and_publish_docs.yml b/.github/workflows/build_and_publish_docs.yml index 054749bff..f0e27e74d 100644 --- a/.github/workflows/build_and_publish_docs.yml +++ b/.github/workflows/build_and_publish_docs.yml @@ -43,7 +43,7 @@ jobs: TG_API_HASH: ${{ secrets.TG_API_HASH }} TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }} run: | - poe docs + poetry run poe docs - name: remove jekyll theming run: touch docs/build/.nojekyll diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index e0aa29a2b..6cce5c929 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -33,4 +33,4 @@ jobs: - name: run codestyle run: | - poe lint + poetry run poe lint diff --git a/.github/workflows/test_coverage.yml b/.github/workflows/test_coverage.yml index 699409755..62087556e 100644 --- a/.github/workflows/test_coverage.yml +++ b/.github/workflows/test_coverage.yml @@ -55,4 +55,4 @@ jobs: TG_API_HASH: ${{ secrets.TG_API_HASH }} TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }} run: | - poe test_all + poetry run poe test_all diff --git a/.github/workflows/test_full.yml b/.github/workflows/test_full.yml index 32459c749..bc4e6d226 100644 --- a/.github/workflows/test_full.yml +++ b/.github/workflows/test_full.yml @@ -44,7 +44,7 @@ jobs: TG_API_HASH: ${{ secrets.TG_API_HASH }} TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }} run: | - poe test_no_cov + poetry run poe test_no_cov test_no_deps: runs-on: "ubuntu-latest" @@ -68,4 +68,4 @@ jobs: TG_API_HASH: ${{ secrets.TG_API_HASH }} TG_BOT_USERNAME: ${{ secrets.TG_BOT_USERNAME }} run: | - poe test_no_deps + poetry run poe test_no_deps diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9aced361c..5728291dc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ We ask that you adhere to the following ## Managing your workflow We use `poetry` and `poethepoet` as handy automation tools, which reads `pyproject.toml` to get specification for commands. -`poetry` is a tool for command running automatization. Usage signature of the `poetry` is `poe COMMAND`. +`poetry` is a tool for command running automatization. Usage signature of the `poetry` is `poetry run poe COMMAND`. If your environment does not support `poetry`, it can be installed as a regular python package with `pip install poetry`. `poethepoet` will be automatically installed upon installation of `devel` dependency group. @@ -56,7 +56,7 @@ to annotate your modules and objects. You can easily build the Sphinx documentat by activating the virtual environment and then running ```bash -poe docs +poetry run poe docs ``` After that `docs/build` dir will be created and you can open index file `docs/build/index.html` in your browser of choice. @@ -107,28 +107,28 @@ It doesn't take previous formatting into account. See more about [black](https:/ To format your code, run ```bash -poe format +poetry run poe format ``` ### Test We use `black`, `mypy`, `flake8` as code style checkers and `pytest` as unit-test runner. To run unit-tests only, use ```bash -poe test_no_cov +poetry run poe test_no_cov ``` To execute all tests, including integration with DBs and APIs tests, run ```bash -poe test_all +poetry run poe test_all ``` for successful execution of this command `Docker` and `docker-compose` are required. To make sure that the code satisfies only the style requirements, run ```bash -poe lint +poetry run poe lint ``` And if it doesn't, to automatically fix whatever is possible with `black`, run ```bash -poe format +poetry run poe format ``` Tests are configured via [`.env_file`](.env_file). @@ -159,11 +159,11 @@ To launch both groups run docker-compose --profile context_storage --profile stats up ``` -This will be done automatically when running `poe test_all`. +This will be done automatically when running `poetry run poe test_all`. ### Other provided features You can get more info about `poetry` commands by `info`: ```bash -poe info +poetry run poe info ``` diff --git a/pyproject.toml b/pyproject.toml index e1861535f..7801f7b9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,7 +88,7 @@ cryptography = { version = "*", optional = true } requests = { version = "2.31.0", optional = true } pytelegrambotapi = { version = "*", optional = true } opentelemetry-instrumentation = { version = "*", optional = true } -sqlalchemy = { version = "*", extras=["asyncio"], optional = true } +sqlalchemy = { version = "*", extras = ["asyncio"], optional = true } opentelemetry-exporter-otlp = { version = ">=1.20.0", optional = true } [tool.poetry.extras] @@ -139,14 +139,14 @@ optional = true [tool.poetry.group.devel.dependencies] python-on-whales = "0.64.3" python-dotenv = "0.21.1" -poethepoet = "0.24.2" +poethepoet = { version = "0.24.2", extras = ["poetry_plugin"] } [tool.poetry.group.tutorials] optional = true [tool.poetry.group.tutorials.dependencies] -flask = { version = "3.0.0", extras=["async"] } +flask = { version = "3.0.0", extras = ["async"] } psutil = "5.9.5" telethon = "1.31.0" fastapi = "0.103.1" diff --git a/scripts/codestyle.py b/scripts/codestyle.py index 88f73230c..6864a4318 100644 --- a/scripts/codestyle.py +++ b/scripts/codestyle.py @@ -43,7 +43,7 @@ def lint() -> int: lint_result = _run_lint_and_mypy() would_format = _run_black(False) if would_format == 1: - print(("=" * 38) + "\nBad formatting? Run: poe format\n" + ("=" * 38)) + print(("=" * 38) + "\nBad formatting? Run: poetry run poe format\n" + ("=" * 38)) return lint_result or would_format diff --git a/scripts/misc.py b/scripts/misc.py index c7bb9caf1..d3d788106 100644 --- a/scripts/misc.py +++ b/scripts/misc.py @@ -9,25 +9,25 @@ def info(): + "Install development-ready version of framework" ) print(f"{Fore.BLUE}poetry env remove --all{Style.RESET_ALL}: Remove all virtual environments\n") - print(f"{Fore.BLUE}poe info{Style.RESET_ALL}: Display this message again") - print(f"{Fore.BLUE}poe lint{Style.RESET_ALL}: Run linters") - print(f"{Fore.BLUE}poe format{Style.RESET_ALL}: Run formatters") + print(f"{Fore.BLUE}poetry run poe info{Style.RESET_ALL}: Display this message again") + print(f"{Fore.BLUE}poetry run poe lint{Style.RESET_ALL}: Run linters") + print(f"{Fore.BLUE}poetry run poe format{Style.RESET_ALL}: Run formatters") print( - f"{Fore.BLUE}poe test_no_cov{Style.RESET_ALL}:" + f"{Fore.BLUE}poetry run poe test_no_cov{Style.RESET_ALL}:" + " Run tests without coverage, skipping all tests for unavailable services," + " this is the most complete testing without Docker" ) print( - f"{Fore.BLUE}poe test_no_deps{Style.RESET_ALL}:" + f"{Fore.BLUE}poetry run poe test_no_deps{Style.RESET_ALL}:" + " Run tests without any dependencies, allowing skipping everything" ) print( - f"{Fore.BLUE}poe test_all{Style.RESET_ALL}:" + f"{Fore.BLUE}poetry run poe test_all{Style.RESET_ALL}:" + " Run ALL tests, prohibit skipping, run Docker (slow, closest to CI)" ) print( - f"{Fore.BLUE}poe docs{Style.RESET_ALL}:" + f"{Fore.BLUE}poetry run poe docs{Style.RESET_ALL}:" + " Build Sphinx docs; activate your virtual environment before execution" ) - print(f"{Fore.BLUE}poe clean_docs{Style.RESET_ALL}: Remove all documentation build roots") + print(f"{Fore.BLUE}poetry run poe clean_docs{Style.RESET_ALL}: Remove all documentation build roots") print(f"{Fore.BLUE}poen clean{Style.RESET_ALL}: Clean all build artifacts\n")