diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a959058..14fceca 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,3 +1,4 @@ +--- # https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python @@ -6,9 +7,9 @@ name: Python package on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] workflow_dispatch: jobs: @@ -21,25 +22,25 @@ jobs: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install . - python -m pip install flake8 pytest ruff - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - # exit-zero treats all errors as warnings. - flake8 . --count --exit-zero --show-source --statistics - - name: Lint with ruff - run: | - ruff . - - name: Test with pytest - run: | - pytest + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install . + python -m pip install flake8 pytest ruff + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + # exit-zero treats all errors as warnings. + flake8 . --count --exit-zero --show-source --statistics + - name: Lint with ruff + run: | + ruff . + - name: Test with pytest + run: | + pytest diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 02d5ca0..6178831 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -22,19 +22,19 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - 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 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - 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 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..426dc0e --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,7 @@ +--- +# Default state for all rules +default: true + +MD013: false # Disable line-length checking +MD033: + allowed_elements: [img] # Allow embedded image tags as there is no way to resize images in native markdown diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f4b94d1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,65 @@ +--- +exclude: '_pb2.py|_pb2_grpc.py' +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-builtin-literals + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-toml + - id: check-vcs-permalinks + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: destroyed-symlinks + - id: detect-private-key + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: forbid-submodules + - id: mixed-line-ending + - id: trailing-whitespace + - repo: https://github.com/PyCQA/isort + rev: 5.13.1 + hooks: + - id: isort + - repo: https://github.com/psf/black + rev: 23.12.0 + hooks: + - id: black + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.7 + hooks: + - id: ruff + args: [--fix] + - repo: https://github.com/asottile/pyupgrade + rev: v3.15.0 + hooks: + - id: pyupgrade + args: [--py39-plus] + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.33.0 + hooks: + - id: yamllint + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.38.0 + hooks: + - id: markdownlint + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + +ci: + autoupdate_schedule: monthly diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..3f301f1 --- /dev/null +++ b/.yamllint @@ -0,0 +1,9 @@ +--- +extends: default + +rules: + line-length: + level: warning + allow-non-breakable-inline-mappings: true + truthy: + check-keys: false diff --git a/README.md b/README.md index 01ad922..a8d8b71 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ with TextAssistant(credentials) as assistant: ## Limitations/Known issues If you see the issued commands in [My Google Activity](https://myactivity.google.com/myactivity) the library is working fine. If the commands don't have the expected outcome, don't open an issue in this repository. You should instead report the issue directly to Google [here](https://github.com/googlesamples/assistant-sdk-python/issues). Examples of known Google Assistant API issues: + - Broadcast commands don't work unless speakers and device that runs this library are in the same network and IPv6 is disabled in the router - Most queries for media controls don't work - not working: e.g. play music on kitchen speaker, stop kitchen speaker @@ -52,15 +53,14 @@ python -m pip install . python -m pip install grpcio-tools python -m grpc_tools.protoc -Isrc --python_out=src --grpc_python_out=src src/google/assistant/embedded/v1alpha2/embedded_assistant.proto -# Run formatter -python -m pip install isort black -isort . -black . +# Run pre-commit +python -m pip install pre-commit +pre-commit install +pre-commit run --all-files -# Run lint -python -m pip install flake8 ruff -flake8 . -ruff . +# Alternative: run formatter, lint +python -m pip install isort black flake8 ruff +isort . ; black . ; flake8 . ; ruff . --fix # Run tests python -m pip install pytest diff --git a/demo.py b/demo.py index 72881e8..aa2567d 100644 --- a/demo.py +++ b/demo.py @@ -89,7 +89,7 @@ def _main( verbose, grpc_deadline, *args, - **kwargs + **kwargs, ): system_browser = browser_helpers.system_browser # Setup logging.