Use f-strings where possible (#1740)

This commit is contained in:
Franck Nijhof 2020-05-22 13:41:14 +02:00 committed by GitHub
parent f0d46e8671
commit 630d85ec78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 11 additions and 11 deletions

View File

@ -626,7 +626,7 @@ class Addon(AddonModel):
_LOGGER.error("Add-on %s is not available for this Platform", self.slug)
raise AddonsNotSupportedError()
# Restore local add-on informations
# Restore local add-on information
_LOGGER.info("Restore config for addon %s", self.slug)
restore_image = self._image(data[ATTR_SYSTEM])
self.sys_addons.data.restore(

View File

@ -108,7 +108,7 @@ class APIAudio(CoreSysAttributes):
version = body.get(ATTR_VERSION, self.sys_plugins.audio.latest_version)
if version == self.sys_plugins.audio.version:
raise APIError("Version {} is already in use".format(version))
raise APIError(f"Version {version} is already in use")
await asyncio.shield(self.sys_plugins.audio.update(version))
@api_process_raw(CONTENT_TYPE_BINARY)

View File

@ -83,7 +83,7 @@ class APICoreDNS(CoreSysAttributes):
version = body.get(ATTR_VERSION, self.sys_plugins.dns.latest_version)
if version == self.sys_plugins.dns.version:
raise APIError("Version {} is already in use".format(version))
raise APIError(f"Version {version} is already in use")
await asyncio.shield(self.sys_plugins.dns.update(version))
@api_process_raw(CONTENT_TYPE_BINARY)

View File

@ -129,7 +129,7 @@ class APIIngress(CoreSysAttributes):
# Support GET query
if request.query_string:
url = "{}?{}".format(url, request.query_string)
url = f"{url}?{request.query_string}"
# Start proxy
async with self.sys_websession.ws_connect(

View File

@ -62,7 +62,7 @@ class APIMulticast(CoreSysAttributes):
version = body.get(ATTR_VERSION, self.sys_plugins.multicast.latest_version)
if version == self.sys_plugins.multicast.version:
raise APIError("Version {} is already in use".format(version))
raise APIError(f"Version {version} is already in use")
await asyncio.shield(self.sys_plugins.multicast.update(version))
@api_process_raw(CONTENT_TYPE_BINARY)

View File

@ -157,7 +157,7 @@ class APISupervisor(CoreSysAttributes):
version = body.get(ATTR_VERSION, self.sys_updater.version_supervisor)
if version == self.sys_supervisor.version:
raise APIError("Version {} is already in use".format(version))
raise APIError(f"Version {version} is already in use")
await asyncio.shield(self.sys_supervisor.update(version))
@api_process

View File

@ -33,7 +33,7 @@ def key_to_iv(key):
def create_slug(name, date_str):
"""Generate a hash from repository."""
key = "{} - {}".format(date_str, name).lower().encode()
key = f"{date_str} - {name}".lower().encode()
return hashlib.sha1(key).hexdigest()[:8]

View File

@ -38,7 +38,7 @@ ALL_FOLDERS = [FOLDER_HOMEASSISTANT, FOLDER_SHARE, FOLDER_ADDONS, FOLDER_SSL]
def unique_addons(addons_list):
"""Validate that an add-on is unique."""
single = set(addon[ATTR_SLUG] for addon in addons_list)
single = {addon[ATTR_SLUG] for addon in addons_list}
if len(single) != len(addons_list):
raise vol.Invalid("Invalid addon list on snapshot!")

View File

@ -11,7 +11,7 @@ from .repository import Repository
_LOGGER: logging.Logger = logging.getLogger(__name__)
BUILTIN_REPOSITORIES = set((REPOSITORY_CORE, REPOSITORY_LOCAL))
BUILTIN_REPOSITORIES = {REPOSITORY_CORE, REPOSITORY_LOCAL}
class StoreManager(CoreSysAttributes):

View File

@ -91,7 +91,7 @@ class StoreData(CoreSysAttributes):
continue
# Generate slug
addon_slug = "{}_{}".format(repository, addon_config[ATTR_SLUG])
addon_slug = f"{repository}_{addon_config[ATTR_SLUG]}"
# store
addon_config[ATTR_REPOSITORY] = repository

View File

@ -59,7 +59,7 @@ def dns_url(url: str) -> str:
try:
ipaddress.ip_address(address) # matches ipv4 or ipv6 addresses
except ValueError:
raise vol.Invalid("Invalid DNS URL: {}".format(url))
raise vol.Invalid(f"Invalid DNS URL: {url}")
return url