diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..74e05b8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + - package-ecosystem: pip + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..29ce27a --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,9 @@ +categories: + - title: "⬆️ Dependencies" + collapse-after: 1 + labels: + - "dependencies" +template: | + ## What's Changed + + $CHANGES diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml new file mode 100644 index 0000000..61098e8 --- /dev/null +++ b/.github/workflows/pythonpublish.yml @@ -0,0 +1,32 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: + - published + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/py-improv-ble-client + permissions: + id-token: write + steps: + - uses: actions/checkout@v4.1.0 + - name: Set up Python + uses: actions/setup-python@v4.7.0 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1@v1.8.10 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..39ecc65 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,24 @@ +name: Release Drafter + +on: + push: + branches: + - main + +permissions: + contents: read + +jobs: + update_release_draft: + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: read + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "main" + - uses: release-drafter/release-drafter@v5.24.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4ddc2cc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Run Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.3 + - name: Set up Python 3.11 + uses: actions/setup-python@v4.7.0 + with: + python-version: '3.11' + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install -r requirements-test.txt + - name: Check formatting with black + run: | + black improv_ble_client --check --diff + - name: Lint with flake8 + run: | + flake8 improv_ble_client + - name: Lint with isort + run: | + isort improv_ble_client + #- name: Lint with mypy + # run: | + # mypy improv_ble_client + - name: Lint with pylint + run: | + pylint improv_ble_client diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c5fa89 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +.DS_Store +.idea +*.log +tmp/ + +*.py[cod] +*.egg +htmlcov + +.projectile +.venv/ +venv/ +.mypy_cache/ +*.egg-info/ + +# Visual Studio Code +.vscode/* + +dist diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2cf78fe --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Home Assistant Team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/improv_ble_client/py.typed b/improv_ble_client/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..62bcf8c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,111 @@ +[build-system] +requires = ["setuptools~=65.6", "wheel~=0.37.1"] +build-backend = "setuptools.build_meta" + +[project] +name = "py-improv-ble-client" +version = "1.0.0" +license = {text = "MIT"} +description = "API to provision devices which implement Improv via BLE" +readme = "README.md" +requires-python = ">=3.11.0" + +[project.urls] +"Homepage" = "https://github.com/homeassistant-libs/py-improv-ble-client" + +[tool.setuptools] +platforms = ["any"] +zip-safe = true +include-package-data = true + +[tool.setuptools.packages.find] +include = ["improv_ble_client*"] + +[tool.setuptools.package-data] +"*" = ["py.typed"] + +[tool.black] +target-version = ["py311"] +extend-exclude = "/generated/" + +[tool.isort] +# https://github.com/PyCQA/isort/wiki/isort-Settings +profile = "black" +# will group `import x` and `from x import` of the same module. +force_sort_within_sections = true +known_first_party = [ + "improv_ble_client", + "tests", +] +forced_separate = [ + "tests", +] +combine_as_imports = true + +[tool.pylint.MAIN] +py-version = "3.11" +ignore = [ + "tests", +] +# Use a conservative default here; 2 should speed up most setups and not hurt +# any too bad. Override on command line as appropriate. +jobs = 2 +init-hook = """\ + from pathlib import Path; \ + import sys; \ + + from pylint.config import find_default_config_files; \ + + sys.path.append( \ + str(Path(next(find_default_config_files())).parent.joinpath('pylint/plugins')) + ) \ + """ +load-plugins = [ + "pylint.extensions.code_style", + "pylint.extensions.typing", +] + +[tool.pylint.BASIC] +class-const-naming-style = "any" +good-names = [ + "_CMD_T", +] + +[tool.pylint."MESSAGES CONTROL"] +# Reasons disabled: +# format - handled by black +# locally-disabled - it spams too much +# duplicate-code - unavoidable +# cyclic-import - doesn't test if both import on load +# abstract-class-little-used - prevents from setting right foundation +# unused-argument - generic callbacks and setup methods create a lot of warnings +# too-many-* - are not enforced for the sake of readability +# too-few-* - same as too-many-* +# abstract-method - with intro of async there are always methods missing +# inconsistent-return-statements - doesn't handle raise +# too-many-ancestors - it's too strict. +# wrong-import-order - isort guards this +# consider-using-f-string - str.format sometimes more readable +disable = [ + "format", + "cyclic-import", + "duplicate-code", + "locally-disabled", + "too-few-public-methods", + "too-many-ancestors", + "too-many-arguments", + "too-many-branches", + "too-many-instance-attributes", + "too-many-lines", + "too-many-locals", + "too-many-public-methods", + "too-many-return-statements", + "too-many-statements", + "too-many-boolean-expressions", + "unused-argument", + "wrong-import-order", +] +enable = [ + "useless-suppression", + "use-symbolic-message-instead", +] diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..4332bf6 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,5 @@ +black==23.7.0 +flake8==6.0.0 +isort==5.12.0 +mypy==1.5.1 +pylint==2.17.4 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d182b39 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +bleak +bleak-retry-connector diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..dc112aa --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[flake8] +# To work with Black +max-line-length = 88 +# E203: Whitespace before ':' +extend-ignore = E203