From b328391af23ff9549938803f55a3732172d435a8 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Thu, 15 Feb 2024 01:36:26 +0400 Subject: [PATCH] chore: GitHub workflow to publish pushes on `main` branch to PyPI chore: create GitHub release for main branch in GitHub workflows chore: create Pyright stub files for Kivy refactor: fix lint issues and typing issues --- .github/workflows/integration_delivery.yml | 213 ++++++++++++++++++ .gitignore | 107 +-------- CHANGELOG.md | 7 + poetry.lock | 187 ++++++++++----- pyproject.toml | 27 ++- ubo_gui/__init__.py | 4 +- ubo_gui/app/__init__.py | 13 +- ubo_gui/constants.py | 4 +- ubo_gui/gauge/__init__.py | 8 +- ubo_gui/menu/__init__.py | 2 +- ubo_gui/menu/constants.py | 3 +- ubo_gui/menu/types.py | 2 +- ubo_gui/menu/widgets/__init__.py | 1 + .../menu/widgets/header_menu_page_widget.py | 3 +- ubo_gui/menu/widgets/item_widget.py | 8 +- .../menu/widgets/normal_menu_page_widget.py | 2 +- ubo_gui/notification/__init__.py | 23 +- ubo_gui/page/__init__.py | 1 + ubo_gui/prompt/__init__.py | 17 +- ubo_gui/volume/__init__.py | 8 +- 20 files changed, 431 insertions(+), 209 deletions(-) create mode 100644 .github/workflows/integration_delivery.yml diff --git a/.github/workflows/integration_delivery.yml b/.github/workflows/integration_delivery.yml new file mode 100644 index 0000000..63cec4a --- /dev/null +++ b/.github/workflows/integration_delivery.yml @@ -0,0 +1,213 @@ +name: CI/CD + +on: + push: + pull_request: + workflow_dispatch: + +env: + PYTHON_VERSION: '3.11' + +jobs: + dependencies: + name: Install Dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + name: Checkout + + - uses: actions/setup-python@v5 + name: Setup Python + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: x64 + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + + - name: Install dependencies + run: poetry install --extras=dev --with dev + + - name: Save Cached Poetry + id: cached-poetry + uses: actions/cache/save@v4 + with: + path: | + ~/.cache + ~/.local + key: poetry-0 + + type-check: + name: Type Check + needs: + - dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + name: Checkout + + - uses: actions/setup-python@v5 + name: Setup Python + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: x64 + + - name: Load Cached Poetry + id: cached-poetry + uses: actions/cache/restore@v4 + with: + path: | + ~/.cache + ~/.local + key: poetry-0 + + - name: Create stub files + run: poetry run pyright --createstub kivy + + - name: Type Check + run: poetry run poe typecheck + + lint: + name: Lint + needs: + - dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + name: Checkout + + - uses: actions/setup-python@v5 + name: Setup Python + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: x64 + + - name: Load Cached Poetry + id: cached-poetry + uses: actions/cache/restore@v4 + with: + path: | + ~/.cache + ~/.local + key: poetry-0 + + - name: Lint + run: poetry run poe lint + + build: + name: Build + needs: + - dependencies + runs-on: ubuntu-latest + outputs: + ubo_app_version: ${{ steps.extract_version.outputs.ubo_app_version }} + steps: + - uses: actions/checkout@v4 + name: Checkout + with: + lfs: true + + - uses: actions/setup-python@v5 + name: Setup Python + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: x64 + + - name: Load Cached Poetry + id: cached-poetry + uses: actions/cache/restore@v4 + with: + path: | + ~/.cache + ~/.local + key: poetry-0 + + - name: Build + run: poetry build + + - name: Extract Version + id: extract_version + run: | + echo "ubo_app_version=$(poetry run python scripts/print_version.py)" >> "$GITHUB_OUTPUT" + + - name: Upload wheel + uses: actions/upload-artifact@v4 + with: + name: wheel + path: dist/*.whl + if-no-files-found: error + + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: binary + path: dist/*.tar.gz + if-no-files-found: error + + pypi-publish: + name: Publish to PyPI + if: >- + github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: + - type-check + - lint + - build + runs-on: ubuntu-latest + environment: + name: PyPI + url: https://pypi.org/p/ubo-app + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: wheel + path: dist + + - uses: actions/download-artifact@v4 + with: + name: binary + path: dist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist + verbose: true + + release: + name: Release + needs: + - type-check + - lint + - build + - pypi-publish + runs-on: ubuntu-latest + permissions: + contents: write + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - name: Procure Wheel + uses: actions/download-artifact@v4 + with: + name: wheel + path: artifacts + + - name: Procure Binary + uses: actions/download-artifact@v4 + with: + name: binary + path: artifacts + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: artifacts/* + tag_name: ${{ needs.build.outputs.ubo_app_version }} + body: | + Release of version ${{ needs.build.outputs.ubo_app_version }} + PyPI package: https://pypi.org/project/ubo-app/${{ needs.build.outputs.ubo_app_version }} + prerelease: false + draft: false diff --git a/.gitignore b/.gitignore index 2641d43..0f9f385 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Gitignore for the following technologies: Python +.DS_Store # Byte-compiled / optimized / DLL files __pycache__/ @@ -57,69 +57,8 @@ cover/ *.mo *.pot -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - # pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py +.python-version # Environments .env @@ -130,42 +69,8 @@ ENV/ env.bak/ venv.bak/ -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ +# pyright +/typings/ -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration -poetry.toml - -# ruff -.ruff_cache/ - -/ubo_gui/assets/ -.DS_Store +# logs +*.log diff --git a/CHANGELOG.md b/CHANGELOG.md index b496aff..0214655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Version 0.9.4 + +- chore: GitHub workflow to publish pushes on `main` branch to PyPI +- chore: create GitHub release for main branch in GitHub workflows +- chore: create Pyright stub files for Kivy +- refactor: fix lint issues and typing issues + ## Version 0.9.3 - fix: close_application now actually closes the passed application diff --git a/poetry.lock b/poetry.lock index c01709b..8ee420b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,13 +2,13 @@ [[package]] name = "adafruit-blinka" -version = "8.31.0" +version = "8.32.0" description = "CircuitPython APIs for non-CircuitPython versions of Python such as CPython on Linux and MicroPython." optional = true python-versions = ">=3.7.0" files = [ - {file = "Adafruit-Blinka-8.31.0.tar.gz", hash = "sha256:720edca821066022e912dffcb364ea04bd3e3f208132b975876a21b2a2daa850"}, - {file = "Adafruit_Blinka-8.31.0-py3-none-any.whl", hash = "sha256:179f7a4312bfe023525040e0a34f490ac44e8f0bf9fc7ab60aa944cf68db6a7e"}, + {file = "Adafruit-Blinka-8.32.0.tar.gz", hash = "sha256:d160bfb8733af58e30da89ca57c19d6f8569f8c9149640776d8ada99f561a744"}, + {file = "Adafruit_Blinka-8.32.0-py3-none-any.whl", hash = "sha256:552c28761c160b78c7cb1202a86c6062beb6911f3393ab208ab9ff47cc8a5949"}, ] [package.dependencies] @@ -67,13 +67,13 @@ typing-extensions = ">=4.0,<5.0" [[package]] name = "adafruit-circuitpython-requests" -version = "2.0.4" +version = "2.0.5" description = "A requests-like library for web interfacing" optional = true python-versions = "*" files = [ - {file = "adafruit-circuitpython-requests-2.0.4.tar.gz", hash = "sha256:7d5e66de34d8b096b275f92142f9d867990abc808361263e4c1e1155d705bb35"}, - {file = "adafruit_circuitpython_requests-2.0.4-py3-none-any.whl", hash = "sha256:d72290a83351cb4cb9cfe75b03f55301d158095c2fc04052a90a825ec060b67b"}, + {file = "adafruit-circuitpython-requests-2.0.5.tar.gz", hash = "sha256:539ae0a526b757dde1dc840b697d08e7f83f8c6de4f6c83eb06f2ea330902a99"}, + {file = "adafruit_circuitpython_requests-2.0.5-py3-none-any.whl", hash = "sha256:c8183b97305ad6b51c60be1f021a512dfddfc47e34e37eef0b2e807fdfc6192c"}, ] [package.dependencies] @@ -96,13 +96,13 @@ adafruit-circuitpython-busdevice = "*" [[package]] name = "adafruit-circuitpython-typing" -version = "1.9.6" +version = "1.10.2" description = "Types needed for type annotation that are not in `typing`" optional = true python-versions = "*" files = [ - {file = "adafruit-circuitpython-typing-1.9.6.tar.gz", hash = "sha256:dc69ed6362dcb890f7103d4da0db94b7d1849bc66804598d34508f413724d152"}, - {file = "adafruit_circuitpython_typing-1.9.6-py3-none-any.whl", hash = "sha256:96de554cfc9d269db72aa4d3b902923815f2d3f488fce3533c6ea07b388ba557"}, + {file = "adafruit-circuitpython-typing-1.10.2.tar.gz", hash = "sha256:ecfbaae7ac0f41b202aa3ed98cbd0f696b17e83b7e7f3fac6dc6a228cbc1c6c6"}, + {file = "adafruit_circuitpython_typing-1.10.2-py3-none-any.whl", hash = "sha256:e64bbf2f7d4a4bdf0f9be8e039cfe2ed199aa7d51aa44a090d50be4f0917d24f"}, ] [package.dependencies] @@ -113,13 +113,13 @@ typing-extensions = ">=4.0,<5.0" [[package]] name = "adafruit-platformdetect" -version = "3.59.0" +version = "3.60.0" description = "Platform detection for use by libraries like Adafruit-Blinka." optional = true python-versions = "*" files = [ - {file = "Adafruit-PlatformDetect-3.59.0.tar.gz", hash = "sha256:cf33e82d164f146f0ee39062879e0caba55e018254db973358566d97ce3d4602"}, - {file = "Adafruit_PlatformDetect-3.59.0-py3-none-any.whl", hash = "sha256:2b27f8a205b43bc0d214cbb3de7eab42b9dcc8d23f224e0e536c6d5195c36e18"}, + {file = "Adafruit-PlatformDetect-3.60.0.tar.gz", hash = "sha256:644deb113c00ba1bfba4703fcd80cab52b5638d4a1146f2d58378df4af09746f"}, + {file = "Adafruit_PlatformDetect-3.60.0-py3-none-any.whl", hash = "sha256:4e5219f187330dfb4026f8fe169acd754f2cd739af07160215bbbe4df7ba8231"}, ] [[package]] @@ -135,13 +135,13 @@ files = [ [[package]] name = "certifi" -version = "2023.11.17" +version = "2024.2.2" description = "Python package for providing Mozilla's CA Bundle." optional = true python-versions = ">=3.6" files = [ - {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, - {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, + {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, + {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, ] [[package]] @@ -492,49 +492,63 @@ files = [ [package.dependencies] requests = "*" +[[package]] +name = "nodeenv" +version = "1.8.0" +description = "Node.js virtual environment builder" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, + {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, +] + +[package.dependencies] +setuptools = "*" + [[package]] name = "numpy" -version = "1.26.3" +version = "1.26.4" description = "Fundamental package for array computing in Python" optional = true python-versions = ">=3.9" files = [ - {file = "numpy-1.26.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:806dd64230dbbfaca8a27faa64e2f414bf1c6622ab78cc4264f7f5f028fee3bf"}, - {file = "numpy-1.26.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:02f98011ba4ab17f46f80f7f8f1c291ee7d855fcef0a5a98db80767a468c85cd"}, - {file = "numpy-1.26.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d45b3ec2faed4baca41c76617fcdcfa4f684ff7a151ce6fc78ad3b6e85af0a6"}, - {file = "numpy-1.26.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bdd2b45bf079d9ad90377048e2747a0c82351989a2165821f0c96831b4a2a54b"}, - {file = "numpy-1.26.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:211ddd1e94817ed2d175b60b6374120244a4dd2287f4ece45d49228b4d529178"}, - {file = "numpy-1.26.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b1240f767f69d7c4c8a29adde2310b871153df9b26b5cb2b54a561ac85146485"}, - {file = "numpy-1.26.3-cp310-cp310-win32.whl", hash = "sha256:21a9484e75ad018974a2fdaa216524d64ed4212e418e0a551a2d83403b0531d3"}, - {file = "numpy-1.26.3-cp310-cp310-win_amd64.whl", hash = "sha256:9e1591f6ae98bcfac2a4bbf9221c0b92ab49762228f38287f6eeb5f3f55905ce"}, - {file = "numpy-1.26.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b831295e5472954104ecb46cd98c08b98b49c69fdb7040483aff799a755a7374"}, - {file = "numpy-1.26.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9e87562b91f68dd8b1c39149d0323b42e0082db7ddb8e934ab4c292094d575d6"}, - {file = "numpy-1.26.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c66d6fec467e8c0f975818c1796d25c53521124b7cfb760114be0abad53a0a2"}, - {file = "numpy-1.26.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f25e2811a9c932e43943a2615e65fc487a0b6b49218899e62e426e7f0a57eeda"}, - {file = "numpy-1.26.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:af36e0aa45e25c9f57bf684b1175e59ea05d9a7d3e8e87b7ae1a1da246f2767e"}, - {file = "numpy-1.26.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:51c7f1b344f302067b02e0f5b5d2daa9ed4a721cf49f070280ac202738ea7f00"}, - {file = "numpy-1.26.3-cp311-cp311-win32.whl", hash = "sha256:7ca4f24341df071877849eb2034948459ce3a07915c2734f1abb4018d9c49d7b"}, - {file = "numpy-1.26.3-cp311-cp311-win_amd64.whl", hash = "sha256:39763aee6dfdd4878032361b30b2b12593fb445ddb66bbac802e2113eb8a6ac4"}, - {file = "numpy-1.26.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a7081fd19a6d573e1a05e600c82a1c421011db7935ed0d5c483e9dd96b99cf13"}, - {file = "numpy-1.26.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12c70ac274b32bc00c7f61b515126c9205323703abb99cd41836e8125ea0043e"}, - {file = "numpy-1.26.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f784e13e598e9594750b2ef6729bcd5a47f6cfe4a12cca13def35e06d8163e3"}, - {file = "numpy-1.26.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f24750ef94d56ce6e33e4019a8a4d68cfdb1ef661a52cdaee628a56d2437419"}, - {file = "numpy-1.26.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:77810ef29e0fb1d289d225cabb9ee6cf4d11978a00bb99f7f8ec2132a84e0166"}, - {file = "numpy-1.26.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8ed07a90f5450d99dad60d3799f9c03c6566709bd53b497eb9ccad9a55867f36"}, - {file = "numpy-1.26.3-cp312-cp312-win32.whl", hash = "sha256:f73497e8c38295aaa4741bdfa4fda1a5aedda5473074369eca10626835445511"}, - {file = "numpy-1.26.3-cp312-cp312-win_amd64.whl", hash = "sha256:da4b0c6c699a0ad73c810736303f7fbae483bcb012e38d7eb06a5e3b432c981b"}, - {file = "numpy-1.26.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1666f634cb3c80ccbd77ec97bc17337718f56d6658acf5d3b906ca03e90ce87f"}, - {file = "numpy-1.26.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:18c3319a7d39b2c6a9e3bb75aab2304ab79a811ac0168a671a62e6346c29b03f"}, - {file = "numpy-1.26.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b7e807d6888da0db6e7e75838444d62495e2b588b99e90dd80c3459594e857b"}, - {file = "numpy-1.26.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4d362e17bcb0011738c2d83e0a65ea8ce627057b2fdda37678f4374a382a137"}, - {file = "numpy-1.26.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b8c275f0ae90069496068c714387b4a0eba5d531aace269559ff2b43655edd58"}, - {file = "numpy-1.26.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:cc0743f0302b94f397a4a65a660d4cd24267439eb16493fb3caad2e4389bccbb"}, - {file = "numpy-1.26.3-cp39-cp39-win32.whl", hash = "sha256:9bc6d1a7f8cedd519c4b7b1156d98e051b726bf160715b769106661d567b3f03"}, - {file = "numpy-1.26.3-cp39-cp39-win_amd64.whl", hash = "sha256:867e3644e208c8922a3be26fc6bbf112a035f50f0a86497f98f228c50c607bb2"}, - {file = "numpy-1.26.3-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:3c67423b3703f8fbd90f5adaa37f85b5794d3366948efe9a5190a5f3a83fc34e"}, - {file = "numpy-1.26.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46f47ee566d98849323f01b349d58f2557f02167ee301e5e28809a8c0e27a2d0"}, - {file = "numpy-1.26.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a8474703bffc65ca15853d5fd4d06b18138ae90c17c8d12169968e998e448bb5"}, - {file = "numpy-1.26.3.tar.gz", hash = "sha256:697df43e2b6310ecc9d95f05d5ef20eacc09c7c4ecc9da3f235d39e71b7da1e4"}, + {file = "numpy-1.26.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9ff0f4f29c51e2803569d7a51c2304de5554655a60c5d776e35b4a41413830d0"}, + {file = "numpy-1.26.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2e4ee3380d6de9c9ec04745830fd9e2eccb3e6cf790d39d7b98ffd19b0dd754a"}, + {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d209d8969599b27ad20994c8e41936ee0964e6da07478d6c35016bc386b66ad4"}, + {file = "numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ffa75af20b44f8dba823498024771d5ac50620e6915abac414251bd971b4529f"}, + {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:62b8e4b1e28009ef2846b4c7852046736bab361f7aeadeb6a5b89ebec3c7055a"}, + {file = "numpy-1.26.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a4abb4f9001ad2858e7ac189089c42178fcce737e4169dc61321660f1a96c7d2"}, + {file = "numpy-1.26.4-cp310-cp310-win32.whl", hash = "sha256:bfe25acf8b437eb2a8b2d49d443800a5f18508cd811fea3181723922a8a82b07"}, + {file = "numpy-1.26.4-cp310-cp310-win_amd64.whl", hash = "sha256:b97fe8060236edf3662adfc2c633f56a08ae30560c56310562cb4f95500022d5"}, + {file = "numpy-1.26.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4c66707fabe114439db9068ee468c26bbdf909cac0fb58686a42a24de1760c71"}, + {file = "numpy-1.26.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:edd8b5fe47dab091176d21bb6de568acdd906d1887a4584a15a9a96a1dca06ef"}, + {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7ab55401287bfec946ced39700c053796e7cc0e3acbef09993a9ad2adba6ca6e"}, + {file = "numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:666dbfb6ec68962c033a450943ded891bed2d54e6755e35e5835d63f4f6931d5"}, + {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:96ff0b2ad353d8f990b63294c8986f1ec3cb19d749234014f4e7eb0112ceba5a"}, + {file = "numpy-1.26.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:60dedbb91afcbfdc9bc0b1f3f402804070deed7392c23eb7a7f07fa857868e8a"}, + {file = "numpy-1.26.4-cp311-cp311-win32.whl", hash = "sha256:1af303d6b2210eb850fcf03064d364652b7120803a0b872f5211f5234b399f20"}, + {file = "numpy-1.26.4-cp311-cp311-win_amd64.whl", hash = "sha256:cd25bcecc4974d09257ffcd1f098ee778f7834c3ad767fe5db785be9a4aa9cb2"}, + {file = "numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b3ce300f3644fb06443ee2222c2201dd3a89ea6040541412b8fa189341847218"}, + {file = "numpy-1.26.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:03a8c78d01d9781b28a6989f6fa1bb2c4f2d51201cf99d3dd875df6fbd96b23b"}, + {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9fad7dcb1aac3c7f0584a5a8133e3a43eeb2fe127f47e3632d43d677c66c102b"}, + {file = "numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:675d61ffbfa78604709862923189bad94014bef562cc35cf61d3a07bba02a7ed"}, + {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:ab47dbe5cc8210f55aa58e4805fe224dac469cde56b9f731a4c098b91917159a"}, + {file = "numpy-1.26.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:1dda2e7b4ec9dd512f84935c5f126c8bd8b9f2fc001e9f54af255e8c5f16b0e0"}, + {file = "numpy-1.26.4-cp312-cp312-win32.whl", hash = "sha256:50193e430acfc1346175fcbdaa28ffec49947a06918b7b92130744e81e640110"}, + {file = "numpy-1.26.4-cp312-cp312-win_amd64.whl", hash = "sha256:08beddf13648eb95f8d867350f6a018a4be2e5ad54c8d8caed89ebca558b2818"}, + {file = "numpy-1.26.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7349ab0fa0c429c82442a27a9673fc802ffdb7c7775fad780226cb234965e53c"}, + {file = "numpy-1.26.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:52b8b60467cd7dd1e9ed082188b4e6bb35aa5cdd01777621a1658910745b90be"}, + {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5241e0a80d808d70546c697135da2c613f30e28251ff8307eb72ba696945764"}, + {file = "numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f870204a840a60da0b12273ef34f7051e98c3b5961b61b0c2c1be6dfd64fbcd3"}, + {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:679b0076f67ecc0138fd2ede3a8fd196dddc2ad3254069bcb9faf9a79b1cebcd"}, + {file = "numpy-1.26.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:47711010ad8555514b434df65f7d7b076bb8261df1ca9bb78f53d3b2db02e95c"}, + {file = "numpy-1.26.4-cp39-cp39-win32.whl", hash = "sha256:a354325ee03388678242a4d7ebcd08b5c727033fcff3b2f536aea978e15ee9e6"}, + {file = "numpy-1.26.4-cp39-cp39-win_amd64.whl", hash = "sha256:3373d5d70a5fe74a2c1bb6d2cfd9609ecf686d47a2d7b1d37a8f3b6bf6003aea"}, + {file = "numpy-1.26.4-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:afedb719a9dcfc7eaf2287b839d8198e06dcd4cb5d276a3df279231138e83d30"}, + {file = "numpy-1.26.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95a7476c59002f2f6c590b9b7b998306fba6a5aa646b1e22ddfeaf8f78c3a29c"}, + {file = "numpy-1.26.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7e50d0a0cc3189f9cb0aeb3a6a6af18c16f59f004b866cd2be1c14b36134a4a0"}, + {file = "numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010"}, ] [[package]] @@ -645,6 +659,24 @@ files = [ [package.dependencies] pywin32 = ">=223" +[[package]] +name = "pyright" +version = "1.1.350" +description = "Command line wrapper for pyright" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pyright-1.1.350-py3-none-any.whl", hash = "sha256:f1dde6bcefd3c90aedbe9dd1c573e4c1ddbca8c74bf4fa664dd3b1a599ac9a66"}, + {file = "pyright-1.1.350.tar.gz", hash = "sha256:a8ba676de3a3737ea4d8590604da548d4498cc5ee9ee00b1a403c6db987916c6"}, +] + +[package.dependencies] +nodeenv = ">=1.6.0" + +[package.extras] +all = ["twine (>=3.4.1)"] +dev = ["twine (>=3.4.1)"] + [[package]] name = "pyserial" version = "3.5" @@ -725,6 +757,32 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "ruff" +version = "0.2.1" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:dd81b911d28925e7e8b323e8d06951554655021df8dd4ac3045d7212ac4ba080"}, + {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dc586724a95b7d980aa17f671e173df00f0a2eef23f8babbeee663229a938fec"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c92db7101ef5bfc18e96777ed7bc7c822d545fa5977e90a585accac43d22f18a"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:13471684694d41ae0f1e8e3a7497e14cd57ccb7dd72ae08d56a159d6c9c3e30e"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a11567e20ea39d1f51aebd778685582d4c56ccb082c1161ffc10f79bebe6df35"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:00a818e2db63659570403e44383ab03c529c2b9678ba4ba6c105af7854008105"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be60592f9d218b52f03384d1325efa9d3b41e4c4d55ea022cd548547cc42cd2b"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fbd2288890b88e8aab4499e55148805b58ec711053588cc2f0196a44f6e3d855"}, + {file = "ruff-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3ef052283da7dec1987bba8d8733051c2325654641dfe5877a4022108098683"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7022d66366d6fded4ba3889f73cd791c2d5621b2ccf34befc752cb0df70f5fad"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0a725823cb2a3f08ee743a534cb6935727d9e47409e4ad72c10a3faf042ad5ba"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0034d5b6323e6e8fe91b2a1e55b02d92d0b582d2953a2b37a67a2d7dedbb7acc"}, + {file = "ruff-0.2.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e5cb5526d69bb9143c2e4d2a115d08ffca3d8e0fddc84925a7b54931c96f5c02"}, + {file = "ruff-0.2.1-py3-none-win32.whl", hash = "sha256:6b95ac9ce49b4fb390634d46d6ece32ace3acdd52814671ccaf20b7f60adb232"}, + {file = "ruff-0.2.1-py3-none-win_amd64.whl", hash = "sha256:e3affdcbc2afb6f5bd0eb3130139ceedc5e3f28d206fe49f63073cb9e65988e0"}, + {file = "ruff-0.2.1-py3-none-win_arm64.whl", hash = "sha256:efababa8e12330aa94a53e90a81eb6e2d55f348bc2e71adbf17d9cad23c03ee6"}, + {file = "ruff-0.2.1.tar.gz", hash = "sha256:3b42b5d8677cd0c72b99fcaf068ffc62abb5a19e71b4a3b9cfa50658a0af02f1"}, +] + [[package]] name = "screeninfo" version = "0.8.1" @@ -740,6 +798,22 @@ files = [ Cython = {version = "*", markers = "sys_platform == \"darwin\""} pyobjc-framework-Cocoa = {version = "*", markers = "sys_platform == \"darwin\""} +[[package]] +name = "setuptools" +version = "69.1.0" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "setuptools-69.1.0-py3-none-any.whl", hash = "sha256:c054629b81b946d63a9c6e732bc8b2513a7c3ea645f11d0139a2191d735c60c6"}, + {file = "setuptools-69.1.0.tar.gz", hash = "sha256:850894c4195f09c4ed30dba56213bf7c3f21d86ed6bdaafb5df5972593bfc401"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.1)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + [[package]] name = "tomli" version = "2.0.1" @@ -764,17 +838,18 @@ files = [ [[package]] name = "urllib3" -version = "2.1.0" +version = "2.2.0" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = true python-versions = ">=3.8" files = [ - {file = "urllib3-2.1.0-py3-none-any.whl", hash = "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"}, - {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, + {file = "urllib3-2.2.0-py3-none-any.whl", hash = "sha256:ce3711610ddce217e6d113a2732fafad960a03fd0318c91faa79481e35c11224"}, + {file = "urllib3-2.2.0.tar.gz", hash = "sha256:051d961ad0c62a94e50ecf1af379c3aba230c66c710493493560c0c223c49f20"}, ] [package.extras] brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] @@ -785,4 +860,4 @@ dev = ["headless-kivy-pi", "headless-kivy-pi"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "484734e49c5125b51499ea04f7cd3a0bc7f60910aceaa24955aa4e31e2fced3f" +content-hash = "32ed6b0e01c04ee5d7510bbae6d398b733da4978f0f7df201395d2f0283e174c" diff --git a/pyproject.toml b/pyproject.toml index 3a1c4af..d476925 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ubo-gui" -version = "0.9.3" +version = "0.9.4" description = "GUI sdk for Ubo Pod" authors = ["Sassan Haradji "] license = "Apache-2.0" @@ -26,6 +26,13 @@ headless-kivy-pi = [ ] python-immutable = "^1.0.2" +[tool.poetry.group.dev] +optional = true + +[tool.poetry.group.dev.dependencies] +pyright = "^1.1.349" +ruff = "^0.2.1" + [tool.poetry.extras] dev = ['headless-kivy-pi'] default = ['headless-kivy-pi'] @@ -35,20 +42,21 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.poe.tasks] -lint = "pyright -p pyproject.toml ." +lint = "ruff . --unsafe-fixes" +typecheck = "pyright -p pyproject.toml ." +sanity = ["typecheck", "lint"] download_font.shell = "mkdir -p ubo_gui/assets/fonts; wget https://github.com/google/material-design-icons/raw/master/variablefont/MaterialSymbolsOutlined%5BFILL%2CGRAD%2Copsz%2Cwght%5D.ttf -O ./ubo_gui/assets/fonts/MaterialSymbolsOutlined[FILL,GRAD,opsz,wght].ttf" [tool.poe.tasks.deploy_to_device] cmd = 'scripts/deploy.sh' [tool.ruff] -select = ['ALL'] -ignore = [] +lint.select = ['ALL'] +lint.ignore = ['INP001', 'PLR0911', 'D203', 'D213'] +lint.fixable = ['ALL'] +lint.unfixable = [] -fixable = ['ALL'] -unfixable = [] - -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] docstring-quotes = "double" inline-quotes = "single" multiline-quotes = "double" @@ -58,3 +66,6 @@ quote-style = 'single' [tool.isort] profile = "black" + +[tool.pyright] +exclude = ['typings'] diff --git a/ubo_gui/__init__.py b/ubo_gui/__init__.py index 83b0a1b..3a34a16 100644 --- a/ubo_gui/__init__.py +++ b/ubo_gui/__init__.py @@ -1,5 +1,5 @@ -""" -This module initializes the ubo_gui package and registers various widgets with the Kivy Factory. +"""Initializes the ubo_gui package and registers various widgets using Kivy Factory. + It also defines the paths for assets and fonts used by the package. """ from pathlib import Path diff --git a/ubo_gui/app/__init__.py b/ubo_gui/app/__init__.py index b269125..f55711c 100644 --- a/ubo_gui/app/__init__.py +++ b/ubo_gui/app/__init__.py @@ -1,3 +1,4 @@ +"""The main module for the Ubo GUI.""" from __future__ import annotations import pathlib @@ -5,9 +6,11 @@ from typing import TYPE_CHECKING, cast from headless_kivy_pi import HeadlessWidget -from kivy.app import App, Builder, StringProperty, Widget +from kivy.app import App from kivy.core.text import LabelBase +from kivy.lang.builder import Builder from kivy.metrics import dp +from kivy.properties import StringProperty from kivy.uix.label import Label from ubo_gui import FONTS_PATH @@ -21,13 +24,18 @@ if TYPE_CHECKING: from kivy.uix.boxlayout import BoxLayout + from kivy.uix.widget import Widget class RootWidget(HeadlessWidget): + """The root widget for the `UboApp`.""" + title = StringProperty('UBO', allownone=True) class UboApp(App): + """The main app for the Ubo GUI.""" + def build(self: UboApp) -> Widget | None: """Build the app. This is the landing point for the app. @@ -59,10 +67,12 @@ def build(self: UboApp) -> Widget | None: @cached_property def central(self: UboApp) -> Widget | None: + """The central section of the app.""" return None @cached_property def header(self: UboApp) -> Widget | None: + """The header section of the app.""" header_label = Label(text=self.root.title or '') def title_callback(_: RootWidget, title: str) -> None: @@ -80,4 +90,5 @@ def title_callback(_: RootWidget, title: str) -> None: @cached_property def footer(self: UboApp) -> Widget | None: + """The footer section of the app.""" return None diff --git a/ubo_gui/constants.py b/ubo_gui/constants.py index 2348688..eb3d25d 100644 --- a/ubo_gui/constants.py +++ b/ubo_gui/constants.py @@ -1,5 +1,5 @@ -from kivy.app import Builder - +"""Module to store constants used in the application.""" +from kivy.lang.builder import Builder PRIMARY_COLOR = '#68B7FF' SECONDARY_COLOR = '#363F4B' diff --git a/ubo_gui/gauge/__init__.py b/ubo_gui/gauge/__init__.py index 839e645..3783295 100644 --- a/ubo_gui/gauge/__init__.py +++ b/ubo_gui/gauge/__init__.py @@ -1,8 +1,9 @@ +"""A half circle gauge widget.""" from __future__ import annotations import pathlib -from kivy.app import Builder +from kivy.lang.builder import Builder from kivy.properties import ColorProperty, ListProperty, NumericProperty, StringProperty from kivy.uix.boxlayout import BoxLayout @@ -21,5 +22,6 @@ class GaugeWidget(BoxLayout): _pos = ListProperty([0, 0]) -Builder.load_file(pathlib.Path( - __file__).parent.joinpath('gauge_widget.kv').resolve().as_posix()) +Builder.load_file( + pathlib.Path(__file__).parent.joinpath('gauge_widget.kv').resolve().as_posix(), +) diff --git a/ubo_gui/menu/__init__.py b/ubo_gui/menu/__init__.py index f3c148f..d5282c4 100644 --- a/ubo_gui/menu/__init__.py +++ b/ubo_gui/menu/__init__.py @@ -16,7 +16,7 @@ from typing import TYPE_CHECKING, Any, Callable, Self, Sequence, cast from headless_kivy_pi import HeadlessWidget -from kivy.app import Builder +from kivy.lang.builder import Builder from kivy.properties import AliasProperty, ListProperty from kivy.uix.boxlayout import BoxLayout from kivy.uix.screenmanager import Screen, ScreenManager, TransitionBase diff --git a/ubo_gui/menu/constants.py b/ubo_gui/menu/constants.py index b21bcb8..80e6cfb 100644 --- a/ubo_gui/menu/constants.py +++ b/ubo_gui/menu/constants.py @@ -1,4 +1,5 @@ -from kivy.app import Builder +"""Module for defining constants used in the `Menu` widget.""" +from kivy.lang.builder import Builder from ubo_gui.page import PAGE_MAX_ITEMS diff --git a/ubo_gui/menu/types.py b/ubo_gui/menu/types.py index f618dfa..e2f08ae 100644 --- a/ubo_gui/menu/types.py +++ b/ubo_gui/menu/types.py @@ -20,7 +20,7 @@ from ubo_gui.constants import PRIMARY_COLOR if TYPE_CHECKING: - from kivy.graphics import Color + from kivy.graphics.context_instructions import Color from ubo_gui.page import PageWidget diff --git a/ubo_gui/menu/widgets/__init__.py b/ubo_gui/menu/widgets/__init__.py index e69de29..630a63e 100644 --- a/ubo_gui/menu/widgets/__init__.py +++ b/ubo_gui/menu/widgets/__init__.py @@ -0,0 +1 @@ +"""Widgets used in the `Menu` widget.""" diff --git a/ubo_gui/menu/widgets/header_menu_page_widget.py b/ubo_gui/menu/widgets/header_menu_page_widget.py index 5bd1690..6036e7d 100644 --- a/ubo_gui/menu/widgets/header_menu_page_widget.py +++ b/ubo_gui/menu/widgets/header_menu_page_widget.py @@ -5,7 +5,8 @@ import warnings from typing import TYPE_CHECKING, Any, Sequence -from kivy.app import Builder, StringProperty +from kivy.lang.builder import Builder +from kivy.properties import StringProperty from ubo_gui.menu.constants import PAGE_SIZE from ubo_gui.page import PageWidget diff --git a/ubo_gui/menu/widgets/item_widget.py b/ubo_gui/menu/widgets/item_widget.py index 362502a..6a955bc 100644 --- a/ubo_gui/menu/widgets/item_widget.py +++ b/ubo_gui/menu/widgets/item_widget.py @@ -4,20 +4,20 @@ import pathlib from typing import TYPE_CHECKING, Any, Callable -from kivy.app import Builder -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.label import ( +from kivy.lang.builder import Builder +from kivy.properties import ( BooleanProperty, ColorProperty, ObjectProperty, StringProperty, ) +from kivy.uix.boxlayout import BoxLayout from ubo_gui.constants import PRIMARY_COLOR from ubo_gui.menu.types import process_subscribable_value if TYPE_CHECKING: - from kivy.graphics import Color + from kivy.graphics.context_instructions import Color from ubo_gui.menu.types import Item diff --git a/ubo_gui/menu/widgets/normal_menu_page_widget.py b/ubo_gui/menu/widgets/normal_menu_page_widget.py index e088601..c548ac5 100644 --- a/ubo_gui/menu/widgets/normal_menu_page_widget.py +++ b/ubo_gui/menu/widgets/normal_menu_page_widget.py @@ -1,7 +1,7 @@ """Module for the `NormalMenuPageWidget` class.""" import pathlib -from kivy.app import Builder +from kivy.lang.builder import Builder from ubo_gui.page import PageWidget diff --git a/ubo_gui/notification/__init__.py b/ubo_gui/notification/__init__.py index 062fc69..e3c1084 100644 --- a/ubo_gui/notification/__init__.py +++ b/ubo_gui/notification/__init__.py @@ -1,13 +1,12 @@ +"""Notification widget.""" from __future__ import annotations import pathlib import warnings -from typing import ( - TYPE_CHECKING, - Callable, -) +from typing import TYPE_CHECKING, Callable -from kivy.app import Builder +from immutable import Immutable +from kivy.lang.builder import Builder from kivy.metrics import dp from kivy.properties import ColorProperty, ObjectProperty, StringProperty @@ -19,18 +18,12 @@ from ubo_gui.menu.types import Item -class NotificationAction: +class NotificationAction(Immutable): + """A notification action.""" + title: str callback: Callable - def __init__(self: NotificationAction, *, title: str, callback: Callable) -> None: - self.title = title - self.callback = callback - - def __repr__(self: NotificationAction) -> str: - """Return a string representation of this object.""" - return f'' - class NotificationWidget(PageWidget): """renders a notification.""" @@ -48,6 +41,7 @@ def __init__( *args: object, **kwargs: object, ) -> None: + """Create a new `NotificationWidget` object.""" super().__init__( *args, items=[ @@ -79,7 +73,6 @@ def get_item(self: NotificationWidget, index: int) -> Item | None: def on_dismiss(self: PageWidget) -> None: """Signal when the notification is dismissed.""" - ... Builder.load_file( diff --git a/ubo_gui/page/__init__.py b/ubo_gui/page/__init__.py index dfbbbed..f02e3e2 100644 --- a/ubo_gui/page/__init__.py +++ b/ubo_gui/page/__init__.py @@ -57,6 +57,7 @@ def __init__( kwargs: object Stuff that will get directly passed to the `__init__` method of Kivy's `Screen`. + """ if items and len(items) > PAGE_MAX_ITEMS: msg = f"""`PageWidget` is initialized with more than `MAX_ITEMS`={ diff --git a/ubo_gui/prompt/__init__.py b/ubo_gui/prompt/__init__.py index 1807c3c..a41bc0f 100644 --- a/ubo_gui/prompt/__init__.py +++ b/ubo_gui/prompt/__init__.py @@ -1,3 +1,7 @@ +"""Implements the `PromptWidget` class. + +A widget that renders a prompt with two options. +""" from __future__ import annotations import pathlib @@ -5,7 +9,7 @@ from abc import ABC, abstractmethod from typing import TYPE_CHECKING -from kivy.app import Builder +from kivy.lang.builder import Builder from kivy.properties import ( AliasProperty, BooleanProperty, @@ -24,7 +28,7 @@ class PromptWidgetMetaClass(type(ABC), type(PageWidget)): - ... + """Metaclass merging `ABC` and `PageWidget` for `PromptWidget` class.""" class PromptWidget(PageWidget, ABC, metaclass=PromptWidgetMetaClass): @@ -46,6 +50,7 @@ class PromptWidget(PageWidget, ABC, metaclass=PromptWidgetMetaClass): second_option_color = ColorProperty((1, 1, 1, 1)) def get_first_item(self: PromptWidget) -> ActionItem | None: + """Return the first item of the prompt.""" if self.first_option_label is None: return None return ActionItem( @@ -58,6 +63,7 @@ def get_first_item(self: PromptWidget) -> ActionItem | None: ) def get_second_item(self: PromptWidget) -> ActionItem | None: + """Return the second item of the prompt.""" if self.second_option_label is None: return None return ActionItem( @@ -115,13 +121,6 @@ def second_option_callback( """ return - def __init__( - self: PromptWidget, - items: None = None, - **kwargs: object, - ) -> None: - super().__init__(items=items, **kwargs) - def get_item(self: PromptWidget, index: int) -> Item | None: """Return the page item at the given index.""" if not 1 <= index <= PROMPT_OPTIONS: diff --git a/ubo_gui/volume/__init__.py b/ubo_gui/volume/__init__.py index 6238df6..68cafe6 100644 --- a/ubo_gui/volume/__init__.py +++ b/ubo_gui/volume/__init__.py @@ -1,8 +1,9 @@ +"""A widget that displays a volume bar.""" from __future__ import annotations import pathlib -from kivy.app import Builder +from kivy.lang.builder import Builder from kivy.properties import ColorProperty, NumericProperty from kivy.uix.boxlayout import BoxLayout @@ -17,5 +18,6 @@ class VolumeWidget(BoxLayout): background_color = ColorProperty(SECONDARY_COLOR) -Builder.load_file(pathlib.Path( - __file__).parent.joinpath('volume_widget.kv').resolve().as_posix()) +Builder.load_file( + pathlib.Path(__file__).parent.joinpath('volume_widget.kv').resolve().as_posix(), +)