Check isinstance on collections.abc, not typing classes (#35087)

This commit is contained in:
Ville Skyttä 2020-05-03 00:57:48 +03:00 committed by GitHub
parent 43d63d0fe5
commit 752679c55d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -1,7 +1,8 @@
"""Support for climate devices through the SmartThings cloud API.""" """Support for climate devices through the SmartThings cloud API."""
import asyncio import asyncio
from collections.abc import Iterable
import logging import logging
from typing import Iterable, Optional, Sequence from typing import Optional, Sequence
from pysmartthings import Attribute, Capability from pysmartthings import Attribute, Capability

View file

@ -1,5 +1,6 @@
"""Template helper methods for rendering strings with Home Assistant data.""" """Template helper methods for rendering strings with Home Assistant data."""
import base64 import base64
import collections.abc
from datetime import datetime from datetime import datetime
from functools import wraps from functools import wraps
import json import json
@ -503,7 +504,7 @@ def expand(hass: HomeAssistantType, *args: Any) -> Iterable[State]:
continue continue
elif isinstance(entity, State): elif isinstance(entity, State):
entity_id = entity.entity_id entity_id = entity.entity_id
elif isinstance(entity, Iterable): elif isinstance(entity, collections.abc.Iterable):
search += entity search += entity
continue continue
else: else:

View file

@ -1,10 +1,11 @@
"""Script to check the configuration file.""" """Script to check the configuration file."""
import argparse import argparse
from collections import OrderedDict from collections import OrderedDict
from collections.abc import Mapping, Sequence
from glob import glob from glob import glob
import logging import logging
import os 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 unittest.mock import patch
from homeassistant import bootstrap, core from homeassistant import bootstrap, core
@ -252,7 +253,7 @@ def dump_dict(layer, indent_count=3, listi=False, **kwargs):
indent_str = indent_count * " " indent_str = indent_count * " "
if listi or isinstance(layer, list): if listi or isinstance(layer, list):
indent_str = indent_str[:-1] + "-" indent_str = indent_str[:-1] + "-"
if isinstance(layer, Dict): if isinstance(layer, Mapping):
for key, value in sorted(layer.items(), key=sort_dict_key): for key, value in sorted(layer.items(), key=sort_dict_key):
if isinstance(value, (dict, list)): if isinstance(value, (dict, list)):
print(indent_str, str(key) + ":", line_info(value, **kwargs)) print(indent_str, str(key) + ":", line_info(value, **kwargs))