Improve string formatting v5 (#33697)

* Improve string formatting v5

* Address review comments
This commit is contained in:
springstan authored and GitHub committed 2020-04-05 17:48:55 +02:00
1 parent 39336d3ea3
commit fca90a8ddc
46 files changed
+221 -252

No files matched your search

+1 -1
View File
@@ -182,7 +182,7 @@ def gather_requirements_from_modules(errors, reqs):
try:
module = importlib.import_module(package)
except ImportError as err:
print("{}.py: {}".format(package.replace(".", "/"), err))
print(f"{package.replace('.', '/')}.py: {err}")
errors.append(package)
continue
+1 -3
View File
@@ -48,9 +48,7 @@ def generate_and_validate(integrations: Dict[str, Integration]):
"codeowners", "Code owners need to be valid GitHub handles."
)
parts.append(
"homeassistant/components/{}/* {}".format(domain, " ".join(codeowners))
)
parts.append(f"homeassistant/components/{domain}/* {' '.join(codeowners)}")
parts.append(f"\n{INDIVIDUAL_FILES.strip()}")
+2 -8
View File
@@ -12,12 +12,7 @@ DOCUMENTATION_URL_HOST = "www.home-assistant.io"
DOCUMENTATION_URL_PATH_PREFIX = "/integrations/"
DOCUMENTATION_URL_EXCEPTIONS = ["https://www.home-assistant.io/hassio"]
SUPPORTED_QUALITY_SCALES = [
"gold",
"internal",
"platinum",
"silver",
]
SUPPORTED_QUALITY_SCALES = ["gold", "internal", "platinum", "silver"]
def documentation_url(value: str) -> str:
@@ -68,8 +63,7 @@ def validate_manifest(integration: Integration):
MANIFEST_SCHEMA(integration.manifest)
except vol.Invalid as err:
integration.add_error(
"manifest",
"Invalid manifest: {}".format(humanize_error(integration.manifest, err)),
"manifest", f"Invalid manifest: {humanize_error(integration.manifest, err)}"
)
integration.manifest = None
return
+1 -1
View File
@@ -79,7 +79,7 @@ def validate_services(integration: Integration):
SERVICES_SCHEMA(data)
except vol.Invalid as err:
integration.add_error(
"services", "Invalid services.yaml: {}".format(humanize_error(data, err))
"services", f"Invalid services.yaml: {humanize_error(data, err)}"
)
+4 -4
View File
@@ -79,8 +79,8 @@ def generate_and_validate(integrations: Dict[str, Integration]):
if model in homekit_dict:
integration.add_error(
"zeroconf",
"Integrations {} and {} have overlapping HomeKit "
"models".format(domain, homekit_dict[model]),
f"Integrations {domain} and {homekit_dict[model]} "
"have overlapping HomeKit models",
)
break
@@ -100,8 +100,8 @@ def generate_and_validate(integrations: Dict[str, Integration]):
if key.startswith(key_2) or key_2.startswith(key):
integration.add_error(
"zeroconf",
"Integrations {} and {} have overlapping HomeKit "
"models".format(homekit_dict[key], homekit_dict[key_2]),
f"Integrations {homekit_dict[key]} and {homekit_dict[key_2]} "
"have overlapping HomeKit models",
)
warned.add(key)
warned.add(key_2)
+2 -4
View File
@@ -61,7 +61,7 @@ async def async_exec(*args, display=False):
argsp = []
for arg in args:
if os.path.isfile(arg):
argsp.append("\\\n {}".format(shlex.quote(arg)))
argsp.append(f"\\\n {shlex.quote(arg)}")
else:
argsp.append(shlex.quote(arg))
printc("cyan", *argsp)
@@ -75,9 +75,7 @@ async def async_exec(*args, display=False):
kwargs["stderr"] = asyncio.subprocess.PIPE
proc = await asyncio.create_subprocess_exec(*args, **kwargs)
except FileNotFoundError as err:
printc(
FAIL, f"Could not execute {args[0]}. Did you install test requirements?",
)
printc(FAIL, f"Could not execute {args[0]}. Did you install test requirements?")
raise err
if not display: