From 026615f986d791333e834a18d5533575b512d492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 2 May 2020 23:23:50 +0300 Subject: [PATCH] Check isinstance on collections.abc, not typing classes --- homeassistant/components/smartthings/climate.py | 3 ++- homeassistant/helpers/template.py | 3 ++- homeassistant/scripts/check_config.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/smartthings/climate.py b/homeassistant/components/smartthings/climate.py index e9c0e749ca884..6ce872cdac7ab 100644 --- a/homeassistant/components/smartthings/climate.py +++ b/homeassistant/components/smartthings/climate.py @@ -1,7 +1,8 @@ """Support for climate devices through the SmartThings cloud API.""" import asyncio +from collections.abc import Iterable import logging -from typing import Iterable, Optional, Sequence +from typing import Optional, Sequence from pysmartthings import Attribute, Capability diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 3f9924d00d58c..bc868fa16b8ec 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -1,5 +1,6 @@ """Template helper methods for rendering strings with Home Assistant data.""" import base64 +import collections.abc from datetime import datetime from functools import wraps import json @@ -503,7 +504,7 @@ def expand(hass: HomeAssistantType, *args: Any) -> Iterable[State]: continue elif isinstance(entity, State): entity_id = entity.entity_id - elif isinstance(entity, Iterable): + elif isinstance(entity, collections.abc.Iterable): search += entity continue else: diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index 627f5b9d976c1..8b4c6a446f215 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -1,10 +1,11 @@ """Script to check the configuration file.""" import argparse from collections import OrderedDict +from collections.abc import Mapping, Sequence from glob import glob import logging import os -from typing import Any, Callable, Dict, List, Sequence, Tuple +from typing import Any, Callable, Dict, List, Tuple from unittest.mock import patch from homeassistant import bootstrap, core @@ -252,7 +253,7 @@ def sort_dict_key(val): indent_str = indent_count * " " if listi or isinstance(layer, list): indent_str = indent_str[:-1] + "-" - if isinstance(layer, Dict): + if isinstance(layer, Mapping): for key, value in sorted(layer.items(), key=sort_dict_key): if isinstance(value, (dict, list)): print(indent_str, str(key) + ":", line_info(value, **kwargs))