diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 646ef91..1c57d08 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,4 +1,4 @@ -name: Run pytest +name: Tests on: pull_request: @@ -9,14 +9,23 @@ jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.11', '3.10'] + steps: - name: Checkout code uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pytest + pip install tox - - name: Run pytest - run: pytest + - name: Run tox + run: tox diff --git a/README.md b/README.md index 44bdba0..cf0a451 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ Install via the extensions tab on the [AUTOMATIC1111 webui](https://github.com/A Developed using existing [AUTOMATIC1111 webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) dependencies. +It's recommended to use the python version specified by A111 webui. + However - for running unit tests, we use pytest. ```bash diff --git a/aspect_ratio_helper/_components.py b/aspect_ratio_helper/_components.py index 22530c0..be6a139 100644 --- a/aspect_ratio_helper/_components.py +++ b/aspect_ratio_helper/_components.py @@ -1,6 +1,7 @@ from abc import ABC from abc import abstractmethod from functools import partial +from typing import Callable import gradio as gr @@ -190,7 +191,7 @@ class PredefinedAspectRatioButtons(ArhUIComponent): ) @property - def display_func(self) -> callable: + def display_func(self) -> Callable[[str], str]: return lambda _: None # todo: different displays for aspect ratios. @@ -268,7 +269,7 @@ class PredefinedPercentageButtons(ArhUIComponent): ) @property - def display_func(self) -> callable: + def display_func(self) -> Callable[[str], str]: return _settings.PREDEFINED_PERCENTAGES_DISPLAY_MAP.get( _settings.safe_opt( _constants.ARH_PREDEFINED_PERCENTAGES_DISPLAY_KEY, diff --git a/aspect_ratio_helper/_util.py b/aspect_ratio_helper/_util.py index f8850ef..c311fd4 100644 --- a/aspect_ratio_helper/_util.py +++ b/aspect_ratio_helper/_util.py @@ -3,7 +3,7 @@ import contextlib import aspect_ratio_helper._constants as _const -def safe_opt_util(shared_opts, key, default_key_map): +def safe_opt_util(shared_opts, key, default_key_map: dict[str, object]): # attempt to retrieve key from shared options with contextlib.suppress(AttributeError): value = shared_opts.__getattr__(key) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..4c6cac4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,6 @@ +[tox] +envlist = py310, py311 + +[testenv] +deps = pytest +commands = pytest