mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Update pyupgrade to 3.1.0 (#80058)
* Update pyupgrade to 3.1.0 * Remove redundant open modes - text is the default
This commit is contained in:
parent
884577e622
commit
4e5b5dfb93
@ -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]
|
||||
|
@ -375,7 +375,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
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")
|
||||
|
||||
|
@ -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__)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user