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

@ -103,9 +103,9 @@ LABEL "com.github.actions.color"="gray-dark"
"""
def _get_package_versions(file: str, packages: set[str]) -> dict[str, str]:
def _get_package_versions(file: Path, packages: set[str]) -> dict[str, str]:
package_versions: dict[str, str] = {}
with open(file, encoding="UTF-8") as fp:
with file.open(encoding="UTF-8") as fp:
for _, line in enumerate(fp):
if package_versions.keys() == packages:
return package_versions
@ -173,10 +173,10 @@ def _generate_files(config: Config) -> list[File]:
) * 1000
package_versions = _get_package_versions(
"requirements_test.txt", {"pipdeptree", "tqdm", "uv"}
Path("requirements_test.txt"), {"pipdeptree", "tqdm", "uv"}
)
package_versions |= _get_package_versions(
"requirements_test_pre_commit.txt", {"ruff"}
Path("requirements_test_pre_commit.txt"), {"ruff"}
)
return [