mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 16:00:23 +00:00
[core] Enable ruff PTH (flake8-use-pathlib) lint family (#16661)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
# pylint: disable=import-error
|
||||
@@ -34,10 +35,10 @@ DOMAINS = {
|
||||
|
||||
|
||||
def sub(path, pattern, repl):
|
||||
with open(path, encoding="utf-8") as handle:
|
||||
with Path(path).open(encoding="utf-8") as handle:
|
||||
content = handle.read()
|
||||
content = re.sub(pattern, repl, content, flags=re.MULTILINE)
|
||||
with open(path, "w", encoding="utf-8") as handle:
|
||||
with Path(path).open("w", encoding="utf-8") as handle:
|
||||
handle.write(content)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user