1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Make typing checks more strict (#14429)

## Description:

Make typing checks more strict: add `--strict-optional` flag that forbids implicit None return type. This flag will become default in the next version of mypy (0.600)

Add `homeassistant/util/` to checked dirs.

## Checklist:
  - [x] The code change is tested and works locally.
  - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
This commit is contained in:
Andrey
2018-07-13 13:24:51 +03:00
committed by GitHub
parent b6ca03ce47
commit c2fe0d0120
17 changed files with 107 additions and 57 deletions

View File

@@ -16,14 +16,20 @@ import logging
import sys
from types import ModuleType
from typing import Optional, Set
# pylint: disable=unused-import
from typing import Dict, List, Optional, Sequence, Set, TYPE_CHECKING # NOQA
from homeassistant.const import PLATFORM_FORMAT
from homeassistant.util import OrderedSet
# Typing imports that create a circular dependency
# pylint: disable=using-constant-test,unused-import
if TYPE_CHECKING:
from homeassistant.core import HomeAssistant # NOQA
PREPARED = False
DEPENDENCY_BLACKLIST = set(('config',))
DEPENDENCY_BLACKLIST = {'config'}
_LOGGER = logging.getLogger(__name__)
@@ -33,7 +39,8 @@ PATH_CUSTOM_COMPONENTS = 'custom_components'
PACKAGE_COMPONENTS = 'homeassistant.components'
def set_component(hass, comp_name: str, component: ModuleType) -> None:
def set_component(hass, # type: HomeAssistant
comp_name: str, component: Optional[ModuleType]) -> None:
"""Set a component in the cache.
Async friendly.