mirror of
https://github.com/esphome/esphome.git
synced 2025-10-08 04:43:46 +01:00
Support multiple --device arguments for address fallback (#10003)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
from esphome import const
|
||||
|
||||
@@ -110,7 +111,7 @@ class RedirectText:
|
||||
def __getattr__(self, item):
|
||||
return getattr(self._out, item)
|
||||
|
||||
def _write_color_replace(self, s):
|
||||
def _write_color_replace(self, s: str | bytes) -> None:
|
||||
from esphome.core import CORE
|
||||
|
||||
if CORE.dashboard:
|
||||
@@ -121,7 +122,7 @@ class RedirectText:
|
||||
s = s.replace("\033", "\\033")
|
||||
self._out.write(s)
|
||||
|
||||
def write(self, s):
|
||||
def write(self, s: str | bytes) -> int:
|
||||
# s is usually a str already (self._out is of type TextIOWrapper)
|
||||
# However, s is sometimes also a bytes object in python3. Let's make sure it's a
|
||||
# str
|
||||
@@ -223,7 +224,7 @@ def run_external_command(
|
||||
return retval
|
||||
|
||||
|
||||
def run_external_process(*cmd, **kwargs):
|
||||
def run_external_process(*cmd: str, **kwargs: Any) -> int | str:
|
||||
full_cmd = " ".join(shlex_quote(x) for x in cmd)
|
||||
_LOGGER.debug("Running: %s", full_cmd)
|
||||
filter_lines = kwargs.get("filter_lines")
|
||||
@@ -266,7 +267,7 @@ class OrderedDict(collections.OrderedDict):
|
||||
return dict(self).__repr__()
|
||||
|
||||
|
||||
def list_yaml_files(folders):
|
||||
def list_yaml_files(folders: list[str]) -> list[str]:
|
||||
files = filter_yaml_files(
|
||||
[os.path.join(folder, p) for folder in folders for p in os.listdir(folder)]
|
||||
)
|
||||
@@ -274,7 +275,7 @@ def list_yaml_files(folders):
|
||||
return files
|
||||
|
||||
|
||||
def filter_yaml_files(files):
|
||||
def filter_yaml_files(files: list[str]) -> list[str]:
|
||||
return [
|
||||
f
|
||||
for f in files
|
||||
|
Reference in New Issue
Block a user