mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:09:12 +00:00
[core] Enable ruff PYI (flake8-pyi) lint family (#16654)
This commit is contained in:
@@ -1077,43 +1077,45 @@ class MockObj(Expression):
|
|||||||
op = BinOpExpression(other, "|", self)
|
op = BinOpExpression(other, "|", self)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __iadd__(self, other: SafeExpType) -> "MockObj":
|
# MockObj operator overloads build a new C++ expression rather than mutating self,
|
||||||
|
# so the PYI034 "augmented assignment returns self" assumption does not apply.
|
||||||
|
def __iadd__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "+=", other)
|
op = BinOpExpression(self, "+=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __isub__(self, other: SafeExpType) -> "MockObj":
|
def __isub__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "-=", other)
|
op = BinOpExpression(self, "-=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __imul__(self, other: SafeExpType) -> "MockObj":
|
def __imul__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "*=", other)
|
op = BinOpExpression(self, "*=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __itruediv__(self, other: SafeExpType) -> "MockObj":
|
def __itruediv__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "/=", other)
|
op = BinOpExpression(self, "/=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __imod__(self, other: SafeExpType) -> "MockObj":
|
def __imod__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "%=", other)
|
op = BinOpExpression(self, "%=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __ilshift__(self, other: SafeExpType) -> "MockObj":
|
def __ilshift__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "<<=", other)
|
op = BinOpExpression(self, "<<=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __irshift__(self, other: SafeExpType) -> "MockObj":
|
def __irshift__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, ">>=", other)
|
op = BinOpExpression(self, ">>=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __iand__(self, other: SafeExpType) -> "MockObj":
|
def __iand__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "&=", other)
|
op = BinOpExpression(self, "&=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __ixor__(self, other: SafeExpType) -> "MockObj":
|
def __ixor__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "^=", other)
|
op = BinOpExpression(self, "^=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
def __ior__(self, other: SafeExpType) -> "MockObj":
|
def __ior__(self, other: SafeExpType) -> "MockObj": # noqa: PYI034
|
||||||
op = BinOpExpression(self, "|=", other)
|
op = BinOpExpression(self, "|=", other)
|
||||||
return MockObj(op)
|
return MockObj(op)
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ def get_esphome_device_ip(
|
|||||||
username: str | None = None,
|
username: str | None = None,
|
||||||
password: str | None = None,
|
password: str | None = None,
|
||||||
client_id: str | None = None,
|
client_id: str | None = None,
|
||||||
timeout: int | float = 25,
|
timeout: float = 25,
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
if CONF_MQTT not in config:
|
if CONF_MQTT not in config:
|
||||||
raise EsphomeError(
|
raise EsphomeError(
|
||||||
|
|||||||
@@ -763,7 +763,7 @@ def parse_yaml(file_name: Path, file_handle: TextIOWrapper, yaml_loader=None) ->
|
|||||||
|
|
||||||
|
|
||||||
def _load_yaml_internal_with_type(
|
def _load_yaml_internal_with_type(
|
||||||
loader_type: type[ESPHomeLoader] | type[ESPHomePurePythonLoader],
|
loader_type: type[ESPHomeLoader | ESPHomePurePythonLoader],
|
||||||
fname: Path,
|
fname: Path,
|
||||||
content: TextIOWrapper,
|
content: TextIOWrapper,
|
||||||
yaml_loader: Callable[[Path], dict[str, Any]],
|
yaml_loader: Callable[[Path], dict[str, Any]],
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ select = [
|
|||||||
"NPY", # numpy-specific rules
|
"NPY", # numpy-specific rules
|
||||||
"PERF", # performance
|
"PERF", # performance
|
||||||
"PL", # pylint
|
"PL", # pylint
|
||||||
|
"PYI", # flake8-pyi
|
||||||
"Q", # flake8-quotes
|
"Q", # flake8-quotes
|
||||||
"RSE", # flake8-raise
|
"RSE", # flake8-raise
|
||||||
"SIM", # flake8-simplify
|
"SIM", # flake8-simplify
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from pathlib import Path
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from typing import Any
|
from typing import Any, Self
|
||||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -5110,11 +5110,11 @@ class MockSerial:
|
|||||||
self.timeout = 0.1
|
self.timeout = 0.1
|
||||||
self._is_open = False
|
self._is_open = False
|
||||||
|
|
||||||
def __enter__(self) -> MockSerial:
|
def __enter__(self) -> Self:
|
||||||
self._is_open = True
|
self._is_open = True
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, *args: Any) -> None:
|
def __exit__(self, *args: object) -> None:
|
||||||
self._is_open = False
|
self._is_open = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Reference in New Issue
Block a user