1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Enable Ruff PTH for the script directory (#124441)

* Enable Ruff PTH for the script directory

* Address review comments

* Fix translations script

* Update script/hassfest/config_flow.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Sid
2024-09-06 11:33:01 +02:00
committed by GitHub
parent 7752789c3a
commit 1db68327f9
18 changed files with 125 additions and 163 deletions

View File

@@ -34,19 +34,15 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
if config.specific_integrations:
return
with open(str(bluetooth_path)) as fp:
current = fp.read()
if current != content:
config.add_error(
"bluetooth",
"File bluetooth.py is not up to date. Run python3 -m script.hassfest",
fixable=True,
)
return
if bluetooth_path.read_text() != content:
config.add_error(
"bluetooth",
"File bluetooth.py is not up to date. Run python3 -m script.hassfest",
fixable=True,
)
def generate(integrations: dict[str, Integration], config: Config) -> None:
"""Generate bluetooth file."""
bluetooth_path = config.root / "homeassistant/generated/bluetooth.py"
with open(str(bluetooth_path), "w") as fp:
fp.write(f"{config.cache['bluetooth']}")
bluetooth_path.write_text(f"{config.cache['bluetooth']}")