diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1dc1c5af289..6da5a570d22 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -620,6 +620,51 @@ jobs: python --version pylint --ignore-missing-annotations=y homeassistant/components/${{ needs.info.outputs.integrations_glob }} + pylint-tests: + name: Check pylint on tests + runs-on: ubuntu-22.04 + timeout-minutes: 20 + if: | + github.event.inputs.mypy-only != 'true' + || github.event.inputs.pylint-only == 'true' + needs: + - info + - base + steps: + - name: Check out code from GitHub + uses: actions/checkout@v4.1.6 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v5.1.0 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + check-latest: true + - name: Restore full Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache/restore@v4.0.2 + with: + path: venv + fail-on-cache-miss: true + key: >- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ + needs.info.outputs.python_cache_key }} + - name: Register pylint problem matcher + run: | + echo "::add-matcher::.github/workflows/matchers/pylint.json" + - name: Run pylint (fully) + if: needs.info.outputs.test_full_suite == 'true' + run: | + . venv/bin/activate + python --version + pylint --ignore-missing-annotations=y tests + - name: Run pylint (partially) + if: needs.info.outputs.test_full_suite == 'false' + shell: bash + run: | + . venv/bin/activate + python --version + pylint --ignore-missing-annotations=y tests/components/${{ needs.info.outputs.integrations_glob }} + mypy: name: Check mypy runs-on: ubuntu-22.04 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5f6377ce7b..023f917d89c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -69,7 +69,7 @@ repos: entry: script/run-in-env.sh pylint -j 0 --ignore-missing-annotations=y language: script types_or: [python, pyi] - files: ^homeassistant/.+\.(py|pyi)$ + files: ^(homeassistant|tests)/.+\.(py|pyi)$ - id: gen_requirements_all name: gen_requirements_all entry: script/run-in-env.sh python3 -m script.gen_requirements_all diff --git a/pyproject.toml b/pyproject.toml index 971f321d3bb..56a10cfcd71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,9 +93,6 @@ include = ["homeassistant*"] [tool.pylint.MAIN] py-version = "3.12" -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