From 4e5b5dfb93c0532f2433d72c3fd80eee1cb082b2 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 11 Oct 2022 09:04:52 +0200 Subject: [PATCH] Update pyupgrade to 3.1.0 (#80058) * Update pyupgrade to 3.1.0 * Remove redundant open modes - text is the default --- .pre-commit-config.yaml | 2 +- homeassistant/components/mqtt/__init__.py | 2 +- homeassistant/config.py | 16 ++++++++-------- requirements_test_pre_commit.txt | 2 +- script/version_bump.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c57b9de8495a..3ba82c4aa5833 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.38.0 + rev: v3.1.0 hooks: - id: pyupgrade args: [--py39-plus] diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 62aad6ca7fe2d..36299c7260894 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -375,7 +375,7 @@ def collect_msg(msg): unsub = await async_subscribe(hass, call.data["topic"], collect_msg) def write_dump(): - with open(hass.config.path("mqtt_dump.txt"), "wt", encoding="utf8") as fp: + with open(hass.config.path("mqtt_dump.txt"), "w", encoding="utf8") as fp: for msg in messages: fp.write(",".join(msg) + "\n") diff --git a/homeassistant/config.py b/homeassistant/config.py index 91f94bbbf40a8..0f68e0bd23546 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -304,26 +304,26 @@ def _write_default_config(config_dir: str) -> bool: # Writing files with YAML does not create the most human readable results # So we're hard coding a YAML template. try: - with open(config_path, "wt", encoding="utf8") as config_file: + with open(config_path, "w", encoding="utf8") as config_file: config_file.write(DEFAULT_CONFIG) if not os.path.isfile(secret_path): - with open(secret_path, "wt", encoding="utf8") as secret_file: + with open(secret_path, "w", encoding="utf8") as secret_file: secret_file.write(DEFAULT_SECRETS) - with open(version_path, "wt", encoding="utf8") as version_file: + with open(version_path, "w", encoding="utf8") as version_file: version_file.write(__version__) if not os.path.isfile(automation_yaml_path): - with open(automation_yaml_path, "wt", encoding="utf8") as automation_file: + with open(automation_yaml_path, "w", encoding="utf8") as automation_file: automation_file.write("[]") if not os.path.isfile(script_yaml_path): - with open(script_yaml_path, "wt", encoding="utf8"): + with open(script_yaml_path, "w", encoding="utf8"): pass if not os.path.isfile(scene_yaml_path): - with open(scene_yaml_path, "wt", encoding="utf8"): + with open(scene_yaml_path, "w", encoding="utf8"): pass return True @@ -421,7 +421,7 @@ def process_ha_config_upgrade(hass: HomeAssistant) -> None: _LOGGER.info("Migrating google tts to google_translate tts") config_raw = config_raw.replace(TTS_PRE_92, TTS_92) try: - with open(config_path, "wt", encoding="utf-8") as config_file: + with open(config_path, "w", encoding="utf-8") as config_file: config_file.write(config_raw) except OSError: _LOGGER.exception("Migrating to google_translate tts failed") @@ -433,7 +433,7 @@ def process_ha_config_upgrade(hass: HomeAssistant) -> None: if os.path.isdir(lib_path): shutil.rmtree(lib_path) - with open(version_path, "wt", encoding="utf8") as outp: + with open(version_path, "w", encoding="utf8") as outp: outp.write(__version__) diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 51789f48ca5d1..87df8c733cba3 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -12,5 +12,5 @@ mccabe==0.6.1 pycodestyle==2.8.0 pydocstyle==6.1.1 pyflakes==2.4.0 -pyupgrade==2.38.0 +pyupgrade==3.1.0 yamllint==1.27.1 diff --git a/script/version_bump.py b/script/version_bump.py index f7dc37b5e22dc..4a38adbd677af 100755 --- a/script/version_bump.py +++ b/script/version_bump.py @@ -116,7 +116,7 @@ def write_version(version): "PATCH_VERSION: Final = .*\n", f'PATCH_VERSION: Final = "{patch}"\n', content ) - with open("homeassistant/const.py", "wt") as fil: + with open("homeassistant/const.py", "w") as fil: fil.write(content)