Add enforce_type_hints to vscode tasks (#74227)

This commit is contained in:
epenet 2022-06-30 20:49:41 +02:00 committed by GitHub
parent 3899c9e6d3
commit 1bfd8b1a76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View File

@ -648,14 +648,14 @@ jobs:
run: |
. venv/bin/activate
python --version
pylint homeassistant
pylint --ignore-missing-annotations=y homeassistant
- name: Run pylint (partially)
if: needs.changes.outputs.test_full_suite == 'false'
shell: bash
run: |
. venv/bin/activate
python --version
pylint homeassistant/components/${{ needs.changes.outputs.integrations_glob }}
pylint --ignore-missing-annotations=y homeassistant/components/${{ needs.changes.outputs.integrations_glob }}
mypy:
name: Check mypy

View File

@ -96,7 +96,7 @@ repos:
files: ^(homeassistant|pylint)/.+\.py$
- id: pylint
name: pylint
entry: script/run-in-env.sh pylint -j 0
entry: script/run-in-env.sh pylint -j 0 --ignore-missing-annotations=y
language: script
types: [python]
files: ^homeassistant/.+\.py$

View File

@ -1268,7 +1268,7 @@ class HassTypeHintChecker(BaseChecker): # type: ignore[misc]
(
"ignore-missing-annotations",
{
"default": True,
"default": False,
"type": "yn",
"metavar": "<y or n>",
"help": "Set to ``no`` if you wish to check functions that do not "

View File

@ -120,6 +120,9 @@ def test_ignore_no_annotations(
hass_enforce_type_hints: ModuleType, type_hint_checker: BaseChecker, code: str
) -> None:
"""Ensure that _is_valid_type is not run if there are no annotations."""
# Set ignore option
type_hint_checker.config.ignore_missing_annotations = True
func_node = astroid.extract_node(
code,
"homeassistant.components.pylint_test",
@ -539,6 +542,9 @@ def test_ignore_invalid_entity_properties(
linter: UnittestLinter, type_hint_checker: BaseChecker
) -> None:
"""Check invalid entity properties are ignored by default."""
# Set ignore option
type_hint_checker.config.ignore_missing_annotations = True
class_node = astroid.extract_node(
"""
class LockEntity():