Use dict syntax (#41325)

This commit is contained in:
Paulus Schoutsen 2020-10-06 15:02:23 +02:00 committed by GitHub
parent 61f919b18c
commit 4d5948b4d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 40 additions and 38 deletions

View file

@ -96,7 +96,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
store[sensor.name] = sensor
_LOGGER.debug(
"Registering new sensor %(name)s => %(event)s",
dict(name=sensor.name, event=event),
{"name": sensor.name, "event": event},
)
async_add_entities((sensor,), True)
else:

View file

@ -172,7 +172,7 @@ async def _async_setup_platform(
# Import CEC IGNORE attributes
pychromecast.IGNORE_CEC += config.get(CONF_IGNORE_CEC, [])
hass.data.setdefault(ADDED_CAST_DEVICES_KEY, set())
hass.data.setdefault(KNOWN_CHROMECAST_INFO_KEY, dict())
hass.data.setdefault(KNOWN_CHROMECAST_INFO_KEY, {})
info = None
if discovery_info is not None:

View file

@ -101,7 +101,7 @@ class Concord232Alarm(alarm.AlarmControlPanelEntity):
except requests.exceptions.ConnectionError as ex:
_LOGGER.error(
"Unable to connect to %(host)s: %(reason)s",
dict(host=self._url, reason=ex),
{"host": self._url, "reason": ex},
)
return
except IndexError:

View file

@ -105,14 +105,14 @@ class GaradgetCover(CoverEntity):
self._name = doorconfig["nme"]
self.update()
except requests.exceptions.ConnectionError as ex:
_LOGGER.error("Unable to connect to server: %(reason)s", dict(reason=ex))
_LOGGER.error("Unable to connect to server: %(reason)s", {"reason": ex})
self._state = STATE_OFFLINE
self._available = False
self._name = DEFAULT_NAME
except KeyError:
_LOGGER.warning(
"Garadget device %(device)s seems to be offline",
dict(device=self.device_id),
{"device": self.device_id},
)
self._name = DEFAULT_NAME
self._state = STATE_OFFLINE
@ -230,12 +230,12 @@ class GaradgetCover(CoverEntity):
self.sensor = status["sensor"]
self._available = True
except requests.exceptions.ConnectionError as ex:
_LOGGER.error("Unable to connect to server: %(reason)s", dict(reason=ex))
_LOGGER.error("Unable to connect to server: %(reason)s", {"reason": ex})
self._state = STATE_OFFLINE
except KeyError:
_LOGGER.warning(
"Garadget device %(device)s seems to be offline",
dict(device=self.device_id),
{"device": self.device_id},
)
self._state = STATE_OFFLINE

View file

@ -50,7 +50,7 @@ class HuaweiDeviceScanner(DeviceScanner):
'"(?P<IPv4Enabled>.*?)","(?P<IPv6Enabled>.*?)",'
'"(?P<DeviceType>.*?)"'
)
LOGIN_COOKIE = dict(Cookie="body:Language:portuguese:id=-1")
LOGIN_COOKIE = {"Cookie": "body:Language:portuguese:id=-1"}
def __init__(self, config):
"""Initialize the scanner."""

View file

@ -158,26 +158,26 @@ class NFAndroidTVNotificationService(BaseNotificationService):
"""Send a message to a Android TV device."""
_LOGGER.debug("Sending notification to: %s", self._target)
payload = dict(
filename=(
payload = {
"filename": (
"icon.png",
self._icon_file,
"application/octet-stream",
{"Expires": "0"},
),
type="0",
title=kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
msg=message,
duration="%i" % self._default_duration,
fontsize="%i" % FONTSIZES.get(self._default_fontsize),
position="%i" % POSITIONS.get(self._default_position),
bkgcolor="%s" % COLORS.get(self._default_color),
transparency="%i" % TRANSPARENCIES.get(self._default_transparency),
offset="0",
app=ATTR_TITLE_DEFAULT,
force="true",
interrupt="%i" % self._default_interrupt,
)
"type": "0",
"title": kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
"msg": message,
"duration": "%i" % self._default_duration,
"fontsize": "%i" % FONTSIZES.get(self._default_fontsize),
"position": "%i" % POSITIONS.get(self._default_position),
"bkgcolor": "%s" % COLORS.get(self._default_color),
"transparency": "%i" % TRANSPARENCIES.get(self._default_transparency),
"offset": "0",
"app": ATTR_TITLE_DEFAULT,
"force": "true",
"interrupt": "%i" % self._default_interrupt,
}
data = kwargs.get(ATTR_DATA)
if data:

View file

@ -171,7 +171,7 @@ class NumatoAPI:
def __init__(self):
"""Initialize API state."""
self.ports_registered = dict()
self.ports_registered = {}
def check_port_free(self, device_id, port, direction):
"""Check whether a port is still free set up.

View file

@ -58,7 +58,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
except requests.exceptions.ConnectionError as ex:
_LOGGER.error(
"Unable to connect to %(host)s: %(reason)s",
dict(host=url, reason=ex),
{"host": url, "reason": ex},
)
raise PlatformNotReady from ex
@ -118,7 +118,7 @@ class NX584Alarm(alarm.AlarmControlPanelEntity):
except requests.exceptions.ConnectionError as ex:
_LOGGER.error(
"Unable to connect to %(host)s: %(reason)s",
dict(host=self._url, reason=ex),
{"host": self._url, "reason": ex},
)
self._state = None
zones = []
@ -132,7 +132,7 @@ class NX584Alarm(alarm.AlarmControlPanelEntity):
if zone["bypassed"]:
_LOGGER.debug(
"Zone %(zone)s is bypassed, assuming HOME",
dict(zone=zone["number"]),
{"zone": zone["number"]},
)
bypassed = True
break

View file

@ -237,7 +237,7 @@ def _create_rfx(config):
def _get_device_lookup(devices):
"""Get a lookup structure for devices."""
lookup = dict()
lookup = {}
for event_code, event_config in devices.items():
event = get_rfx_object(event_code)
if event is None:

View file

@ -59,9 +59,11 @@ class Gateway:
if inner_entry["Buffer"] is not None:
text = text + inner_entry["Buffer"]
event_data = dict(
phone=message["Number"], date=str(message["DateTime"]), message=text
)
event_data = {
"phone": message["Number"],
"date": str(message["DateTime"]),
"message": text,
}
_LOGGER.debug("Append event data:%s", event_data)
data.append(event_data)

View file

@ -152,7 +152,7 @@ class UnifiVideoCamera(Camera):
camera.login()
_LOGGER.debug(
"Logged into UVC camera %(name)s via %(addr)s",
dict(name=self._name, addr=addr),
{"name": self._name, "addr": addr},
)
self._connect_addr = addr
break

View file

@ -52,9 +52,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a Vivotek IP Camera."""
creds = f"{config[CONF_USERNAME]}:{config[CONF_PASSWORD]}"
args = dict(
config=config,
cam=VivotekCamera(
args = {
"config": config,
"cam": VivotekCamera(
host=config[CONF_IP_ADDRESS],
port=(443 if config[CONF_SSL] else 80),
verify_ssl=config[CONF_VERIFY_SSL],
@ -63,8 +63,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
digest_auth=config[CONF_AUTHENTICATION] == HTTP_DIGEST_AUTHENTICATION,
sec_lvl=config[CONF_SECURITY_LEVEL],
),
stream_source=f"rtsp://{creds}@{config[CONF_IP_ADDRESS]}:554/{config[CONF_STREAM_PATH]}",
)
"stream_source": f"rtsp://{creds}@{config[CONF_IP_ADDRESS]}:554/{config[CONF_STREAM_PATH]}",
}
add_entities([VivotekCam(**args)], True)

View file

@ -77,7 +77,7 @@ async def _async_process_dependencies(
if dep not in hass.config.components
}
after_dependencies_tasks = dict()
after_dependencies_tasks = {}
to_be_loaded = hass.data.get(DATA_SETUP_DONE, {})
for dep in integration.after_dependencies:
if (