Skip to content

Commit

Permalink
Don't ignore mypy errors by default (home-assistant#49270)
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI authored Apr 26, 2021
1 parent 0f22000 commit 37466ae
Show file tree
Hide file tree
Showing 12 changed files with 1,373 additions and 33 deletions.
950 changes: 950 additions & 0 deletions .no-strict-typing

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions homeassistant/components/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,12 @@ async def _async_process_config(
blueprints_used = False

for config_key in extract_domain_configs(config, DOMAIN):
conf: list[dict[str, Any] | blueprint.BlueprintInputs] = config[ # type: ignore
config_key
]
conf: list[dict[str, Any] | blueprint.BlueprintInputs] = config[config_key]

for list_no, config_block in enumerate(conf):
raw_blueprint_inputs = None
raw_config = None
if isinstance(config_block, blueprint.BlueprintInputs): # type: ignore
if isinstance(config_block, blueprint.BlueprintInputs):
blueprints_used = True
blueprint_inputs = config_block
raw_blueprint_inputs = blueprint_inputs.config_with_inputs
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/automation/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

@singleton(DATA_BLUEPRINTS)
@callback
def async_get_blueprints(hass: HomeAssistant) -> blueprint.DomainBlueprints: # type: ignore
def async_get_blueprints(hass: HomeAssistant) -> blueprint.DomainBlueprints:
"""Get automation blueprints."""
return blueprint.DomainBlueprints(hass, DOMAIN, LOGGER) # type: ignore
return blueprint.DomainBlueprints(hass, DOMAIN, LOGGER)
4 changes: 2 additions & 2 deletions homeassistant/components/coronavirus/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResultDict:
"""Handle the initial step."""
errors = {}
errors: dict[str, str] = {}

if self._options is None:
coordinator = await get_coordinator(self.hass)
if not coordinator.last_update_success:
if not coordinator.last_update_success or coordinator.data is None:
return self.async_abort(reason="cannot_connect")

self._options = {OPTION_WORLDWIDE: "Worldwide"}
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/knx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def register_callback(self) -> TelegramQueue.Callback:
address_filters = list(
map(AddressFilter, self.config[DOMAIN][CONF_KNX_EVENT_FILTER])
)
return self.xknx.telegram_queue.register_telegram_received_cb( # type: ignore[no-any-return]
return self.xknx.telegram_queue.register_telegram_received_cb(
self.telegram_received_cb,
address_filters=address_filters,
group_addresses=[],
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/picnic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def name(self) -> str | None:
@property
def state(self) -> StateType:
"""Return the state of the entity."""
data_set = self.coordinator.data.get(self.properties["data_type"], {})
data_set = (
self.coordinator.data.get(self.properties["data_type"], {})
if self.coordinator.data is not None
else {}
)
return self.properties["state"](data_set)

@property
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/util/ruamel_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Union

import ruamel.yaml
from ruamel.yaml import YAML # type: ignore
from ruamel.yaml import YAML
from ruamel.yaml.compat import StringIO
from ruamel.yaml.constructor import SafeConstructor
from ruamel.yaml.error import YAMLError
Expand Down Expand Up @@ -91,7 +91,7 @@ def load_yaml(fname: str, round_trip: bool = False) -> JSON_TYPE:
"""Load a YAML file."""
if round_trip:
yaml = YAML(typ="rt")
yaml.preserve_quotes = True
yaml.preserve_quotes = True # type: ignore[assignment]
else:
if ExtSafeConstructor.name is None:
ExtSafeConstructor.name = fname
Expand Down
39 changes: 39 additions & 0 deletions mypy.ini

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions script/hassfest/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
json,
manifest,
mqtt,
mypy_config,
requirements,
services,
ssdp,
Expand All @@ -36,6 +37,7 @@
]
HASS_PLUGINS = [
coverage,
mypy_config,
]


Expand Down
4 changes: 2 additions & 2 deletions script/hassfest/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Config:
errors: list[Error] = attr.ib(factory=list)
cache: dict[str, Any] = attr.ib(factory=dict)

def add_error(self, *args, **kwargs):
def add_error(self, *args: Any, **kwargs: Any) -> None:
"""Add an error."""
self.errors.append(Error(*args, **kwargs))

Expand Down Expand Up @@ -96,7 +96,7 @@ def dependencies(self) -> list[str]:
"""List of dependencies."""
return self.manifest.get("dependencies", [])

def add_error(self, *args, **kwargs):
def add_error(self, *args: Any, **kwargs: Any) -> None:
"""Add an error."""
self.errors.append(Error(*args, **kwargs))

Expand Down
Loading

0 comments on commit 37466ae

Please sign in to comment.