From e3afdf4d9664585859c2cda671d1dcd2b18730ed Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 20 Nov 2023 08:42:10 +0200 Subject: [PATCH] Upgrade CI/lint tools (#111) * Update pre-commit tools * Switch formatting from black to ruff-format * CI: use GitHub output format for Ruff --- .github/workflows/ci.yml | 2 ++ .pre-commit-config.yaml | 11 +++-------- src/dynamicprompts/jinja_extensions.py | 7 +++++-- tests/parser/test_commands.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1532dea..f3474b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: pre-commit/action@v3.0.0 + env: + RUFF_OUTPUT_FORMAT: github mypy: runs-on: ubuntu-latest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ddf7bc2..0fe058d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,13 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.290 + rev: v0.1.6 hooks: - id: ruff args: - --fix + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 23.9.1 - hooks: - - id: black - args: - - --quiet diff --git a/src/dynamicprompts/jinja_extensions.py b/src/dynamicprompts/jinja_extensions.py index b6c37f7..75bc57b 100644 --- a/src/dynamicprompts/jinja_extensions.py +++ b/src/dynamicprompts/jinja_extensions.py @@ -42,8 +42,11 @@ def wildcard(environment: Environment, wildcard_name: str) -> list[str]: from dynamicprompts.generators import CombinatorialPromptGenerator from dynamicprompts.wildcards import WildcardManager - wm: WildcardManager = environment.globals["wildcard_manager"] # type: ignore - generator: CombinatorialPromptGenerator = environment.globals["generators"]["combinatorial"] # type: ignore + wm = cast(WildcardManager, environment.globals["wildcard_manager"]) + generator = cast( + CombinatorialPromptGenerator, + environment.globals["generators"]["combinatorial"], # type: ignore + ) return [str(r) for r in generator.generate(wm.to_wildcard(wildcard_name))] diff --git a/tests/parser/test_commands.py b/tests/parser/test_commands.py index 565d37b..addf117 100644 --- a/tests/parser/test_commands.py +++ b/tests/parser/test_commands.py @@ -62,7 +62,7 @@ def test_combinations(self): variant_command = VariantCommand.from_literals_and_weights(ONE_TWO_THREE) assert [ - v.literal for v, in variant_command.get_value_combinations(1) + v.literal for (v,) in variant_command.get_value_combinations(1) ] == ONE_TWO_THREE assert [