1
0
mirror of https://github.com/home-assistant/core synced 2024-07-03 08:18:59 +00:00

Move disallow-any-generics to mypy.ini (#63917)

This commit is contained in:
Marc Mueller 2022-01-11 22:33:25 +01:00 committed by GitHub
parent f4aa18de31
commit 240c9979c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 73 additions and 44 deletions

View File

@ -2,7 +2,29 @@
# If component is fully covered with type annotations, please add it here
# to enable strict mypy checks.
# Stict typing is enabled by default for core files.
# Add it here to add 'disallow_any_generics'.
# --- Only for core file! ---
homeassistant.exceptions
homeassistant.core
homeassistant.loader
homeassistant.requirements
homeassistant.runner
homeassistant.setup
homeassistant.auth.auth_store
homeassistant.auth.providers.*
homeassistant.helpers.area_registry
homeassistant.helpers.condition
homeassistant.helpers.discovery
homeassistant.helpers.entity_values
homeassistant.helpers.reload
homeassistant.helpers.script_variables
homeassistant.helpers.translation
homeassistant.util.color
homeassistant.util.process
homeassistant.util.unit_system
# --- Add components below this line ---
homeassistant.components
homeassistant.components.abode.*
homeassistant.components.acer_projector.*

View File

@ -22,8 +22,6 @@ from .permissions import system_policies
from .permissions.models import PermissionLookup
from .permissions.types import PolicyType
# mypy: disallow-any-generics
STORAGE_VERSION = 1
STORAGE_KEY = "auth"
GROUP_NAME_ADMIN = "Administrators"

View File

@ -22,8 +22,6 @@ from ..auth_store import AuthStore
from ..const import MFA_SESSION_EXPIRATION
from ..models import Credentials, RefreshToken, User, UserMeta
# mypy: disallow-any-generics
_LOGGER = logging.getLogger(__name__)
DATA_REQS = "auth_prov_reqs_processed"

View File

@ -16,8 +16,6 @@ from homeassistant.exceptions import HomeAssistantError
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
# mypy: disallow-any-generics
CONF_ARGS = "args"
CONF_META = "meta"

View File

@ -18,8 +18,6 @@ from homeassistant.exceptions import HomeAssistantError
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
# mypy: disallow-any-generics
STORAGE_VERSION = 1
STORAGE_KEY = "auth_provider.homeassistant"

View File

@ -14,8 +14,6 @@ from homeassistant.exceptions import HomeAssistantError
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
# mypy: disallow-any-generics
USER_SCHEMA = vol.Schema(
{
vol.Required("username"): str,

View File

@ -19,8 +19,6 @@ import homeassistant.helpers.config_validation as cv
from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from ..models import Credentials, UserMeta
# mypy: disallow-any-generics
AUTH_PROVIDER_TYPE = "legacy_api_password"
CONF_API_PASSWORD = "api_password"

View File

@ -27,8 +27,6 @@ from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow
from .. import InvalidAuthError
from ..models import Credentials, RefreshToken, UserMeta
# mypy: disallow-any-generics
IPAddress = Union[IPv4Address, IPv6Address]
IPNetwork = Union[IPv4Network, IPv6Network]

View File

@ -9,8 +9,6 @@ import attr
if TYPE_CHECKING:
from .core import Context
# mypy: disallow-any-generics
class HomeAssistantError(Exception):
"""General Home Assistant exception occurred."""

View File

@ -14,8 +14,6 @@ from homeassistant.util import slugify
from . import device_registry as dr, entity_registry as er
from .typing import UNDEFINED, UndefinedType
# mypy: disallow-any-generics
DATA_REGISTRY = "area_registry"
EVENT_AREA_REGISTRY_UPDATED = "area_registry_updated"
STORAGE_KEY = "core.area_registry"

View File

@ -70,8 +70,6 @@ from .trace import (
)
from .typing import ConfigType, TemplateVarsType
# mypy: disallow-any-generics
ASYNC_FROM_CONFIG_FORMAT = "async_{}_from_config"
FROM_CONFIG_FORMAT = "{}_from_config"
VALIDATE_CONFIG_FORMAT = "{}_validate_config"

View File

@ -23,8 +23,6 @@ EVENT_LOAD_PLATFORM = "load_platform.{}"
ATTR_PLATFORM = "platform"
ATTR_DISCOVERED = "discovered"
# mypy: disallow-any-generics
class DiscoveryDict(TypedDict):
"""Discovery data."""

View File

@ -8,8 +8,6 @@ from typing import Any
from homeassistant.core import split_entity_id
# mypy: disallow-any-generics
class EntityValues:
"""Class to store entity id based values."""

View File

@ -17,8 +17,6 @@ from . import config_per_platform
from .entity_platform import EntityPlatform, async_get_platforms
from .typing import ConfigType
# mypy: disallow-any-generics
_LOGGER = logging.getLogger(__name__)

View File

@ -8,8 +8,6 @@ from homeassistant.core import HomeAssistant, callback
from . import template
# mypy: disallow-any-generics
class ScriptVariables:
"""Class to hold and render script variables."""

View File

@ -17,8 +17,6 @@ from homeassistant.loader import (
from homeassistant.util.async_ import gather_with_concurrency
from homeassistant.util.json import load_json
# mypy: disallow-any-generics
_LOGGER = logging.getLogger(__name__)
TRANSLATION_LOAD_LOCK = "translation_load_lock"

View File

@ -34,8 +34,6 @@ from .util.async_ import gather_with_concurrency
if TYPE_CHECKING:
from .core import HomeAssistant
# mypy: disallow-any-generics
CALLABLE_T = TypeVar( # pylint: disable=invalid-name
"CALLABLE_T", bound=Callable[..., Any]
)

View File

@ -13,8 +13,6 @@ from .helpers.typing import UNDEFINED, UndefinedType
from .loader import Integration, IntegrationNotFound, async_get_integration
from .util import package as pkg_util
# mypy: disallow-any-generics
PIP_TIMEOUT = 60 # The default is too low when the internet connection is satellite or high latency
MAX_INSTALL_FAILURES = 3
DATA_PIP_LOCK = "pip_lock"

View File

@ -14,8 +14,6 @@ from .helpers.frame import warn_use
from .util.executor import InterruptibleThreadPoolExecutor
from .util.thread import deadlock_safe_shutdown
# mypy: disallow-any-generics
#
# Python 3.8 has significantly less workers by default
# than Python 3.7. In order to be consistent between

View File

@ -22,8 +22,6 @@ from .exceptions import HomeAssistantError
from .helpers.typing import ConfigType
from .util import dt as dt_util, ensure_unique_string
# mypy: disallow-any-generics
_LOGGER = logging.getLogger(__name__)
ATTR_COMPONENT = "component"

View File

@ -7,8 +7,6 @@ from typing import NamedTuple, cast
import attr
# mypy: disallow-any-generics
class RGBColor(NamedTuple):
"""RGB hex values."""

View File

@ -5,8 +5,6 @@ from __future__ import annotations
import subprocess
from typing import Any
# mypy: disallow-any-generics
def kill_subprocess(process: subprocess.Popen[Any]) -> None:
"""Force kill a subprocess and wait for it to exit."""

View File

@ -40,8 +40,6 @@ from . import (
volume as volume_util,
)
# mypy: disallow-any-generics
LENGTH_UNITS = distance_util.VALID_UNITS
MASS_UNITS: tuple[str, ...] = (MASS_POUNDS, MASS_OUNCES, MASS_KILOGRAMS, MASS_GRAMS)

View File

@ -22,9 +22,60 @@ no_implicit_optional = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.exceptions]
disallow_any_generics = true
[mypy-homeassistant.core]
disallow_any_generics = true
[mypy-homeassistant.loader]
disallow_any_generics = true
[mypy-homeassistant.requirements]
disallow_any_generics = true
[mypy-homeassistant.runner]
disallow_any_generics = true
[mypy-homeassistant.setup]
disallow_any_generics = true
[mypy-homeassistant.auth.auth_store]
disallow_any_generics = true
[mypy-homeassistant.auth.providers.*]
disallow_any_generics = true
[mypy-homeassistant.helpers.area_registry]
disallow_any_generics = true
[mypy-homeassistant.helpers.condition]
disallow_any_generics = true
[mypy-homeassistant.helpers.discovery]
disallow_any_generics = true
[mypy-homeassistant.helpers.entity_values]
disallow_any_generics = true
[mypy-homeassistant.helpers.reload]
disallow_any_generics = true
[mypy-homeassistant.helpers.script_variables]
disallow_any_generics = true
[mypy-homeassistant.helpers.translation]
disallow_any_generics = true
[mypy-homeassistant.util.color]
disallow_any_generics = true
[mypy-homeassistant.util.process]
disallow_any_generics = true
[mypy-homeassistant.util.unit_system]
disallow_any_generics = true
[mypy-homeassistant.components.*]
check_untyped_defs = false
disallow_incomplete_defs = false