Use literal string interpolation in core (f-strings) (#26166)
This commit is contained in:
1 parent
1efa29d6ff
commit
decf13b948
67 files changed
+180
-246
No files matched your search
@@ -68,7 +68,7 @@ def main():
|
||||
print()
|
||||
|
||||
for integration in sorted(invalid_itg, key=lambda itg: itg.domain):
|
||||
print("Integration {}:".format(integration.domain))
|
||||
print(f"Integration {integration.domain}:")
|
||||
for error in integration.errors:
|
||||
print("*", error)
|
||||
print()
|
||||
|
||||
@@ -67,5 +67,5 @@ def validate(integrations: Dict[str, Integration], config):
|
||||
for dep in integration.manifest["dependencies"]:
|
||||
if dep not in integrations:
|
||||
integration.add_error(
|
||||
"dependencies", "Dependency {} does not exist".format(dep)
|
||||
"dependencies", f"Dependency {dep} does not exist"
|
||||
)
|
||||
@@ -79,20 +79,20 @@ class Integration:
|
||||
"""Load manifest."""
|
||||
manifest_path = self.path / "manifest.json"
|
||||
if not manifest_path.is_file():
|
||||
self.add_error("model", "Manifest file {} not found".format(manifest_path))
|
||||
self.add_error("model", f"Manifest file {manifest_path} not found")
|
||||
return
|
||||
|
||||
try:
|
||||
manifest = json.loads(manifest_path.read_text())
|
||||
except ValueError as err:
|
||||
self.add_error("model", "Manifest contains invalid JSON: {}".format(err))
|
||||
self.add_error("model", f"Manifest contains invalid JSON: {err}")
|
||||
return
|
||||
|
||||
self.manifest = manifest
|
||||
|
||||
def import_pkg(self, platform=None):
|
||||
"""Import the Python file."""
|
||||
pkg = "homeassistant.components.{}".format(self.domain)
|
||||
pkg = f"homeassistant.components.{self.domain}"
|
||||
if platform is not None:
|
||||
pkg += ".{}".format(platform)
|
||||
pkg += f".{platform}"
|
||||
return importlib.import_module(pkg)
|
||||
Reference in new issue
Block a user