Skip to content

Commit

Permalink
Update pyupgrade to 3.1.0 (home-assistant#80058)
Browse files Browse the repository at this point in the history
* Update pyupgrade to 3.1.0

* Remove redundant open modes - text is the default
  • Loading branch information
cdce8p authored Oct 11, 2022
1 parent 884577e commit 4e5b5df
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
16 changes: 8 additions & 8 deletions homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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__)


Expand Down
2 changes: 1 addition & 1 deletion requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion script/version_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 4e5b5df

Please sign in to comment.