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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 125 additions and 163 deletions

View file

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