mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Upgrade mypy (#23586)
* Upgrade mypy to 0.701 * Enable strict equality checks * Strict equality error fixes * StateMachine.is_state docstring fix
This commit is contained in:
parent
b79d71065c
commit
f434e24252
@ -828,8 +828,8 @@ class StateMachine:
|
||||
"""
|
||||
return self._states.get(entity_id.lower())
|
||||
|
||||
def is_state(self, entity_id: str, state: State) -> bool:
|
||||
"""Test if entity exists and is specified state.
|
||||
def is_state(self, entity_id: str, state: str) -> bool:
|
||||
"""Test if entity exists and is in specified state.
|
||||
|
||||
Async friendly.
|
||||
"""
|
||||
@ -907,7 +907,7 @@ class StateMachine:
|
||||
else:
|
||||
same_state = (old_state.state == new_state and
|
||||
not force_update)
|
||||
same_attr = old_state.attributes == attributes
|
||||
same_attr = old_state.attributes == MappingProxyType(attributes)
|
||||
last_changed = old_state.last_changed if same_state else None
|
||||
|
||||
if same_state and same_attr:
|
||||
|
@ -266,12 +266,12 @@ def color_xy_brightness_to_RGB(
|
||||
vY = xy_closest[1]
|
||||
|
||||
brightness = ibrightness / 255.
|
||||
if brightness == 0:
|
||||
if brightness == 0.0:
|
||||
return (0, 0, 0)
|
||||
|
||||
Y = brightness
|
||||
|
||||
if vY == 0:
|
||||
if vY == 0.0:
|
||||
vY += 0.00000000001
|
||||
|
||||
X = (Y / vY) * vX
|
||||
@ -304,7 +304,7 @@ def color_xy_brightness_to_RGB(
|
||||
|
||||
def color_hsb_to_RGB(fH: float, fS: float, fB: float) -> Tuple[int, int, int]:
|
||||
"""Convert a hsb into its rgb representation."""
|
||||
if fS == 0:
|
||||
if fS == 0.0:
|
||||
fV = int(fB * 255)
|
||||
return fV, fV, fV
|
||||
|
||||
|
@ -117,7 +117,7 @@ def vincenty(point1: Tuple[float, float], point2: Tuple[float, float],
|
||||
cosLambda = math.cos(Lambda)
|
||||
sinSigma = math.sqrt((cosU2 * sinLambda) ** 2 +
|
||||
(cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) ** 2)
|
||||
if sinSigma == 0:
|
||||
if sinSigma == 0.0:
|
||||
return 0.0 # coincident points
|
||||
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda
|
||||
sigma = math.atan2(sinSigma, cosSigma)
|
||||
|
1
mypy.ini
1
mypy.ini
@ -4,6 +4,7 @@ disallow_untyped_calls = true
|
||||
follow_imports = silent
|
||||
ignore_missing_imports = true
|
||||
no_implicit_optional = true
|
||||
strict_equality = true
|
||||
warn_incomplete_stub = true
|
||||
warn_redundant_casts = true
|
||||
warn_return_any = true
|
||||
|
@ -7,7 +7,7 @@ coveralls==1.2.0
|
||||
flake8-docstrings==1.3.0
|
||||
flake8==3.7.7
|
||||
mock-open==1.3.1
|
||||
mypy==0.670
|
||||
mypy==0.701
|
||||
pydocstyle==3.0.0
|
||||
pylint==2.3.1
|
||||
pytest-aiohttp==0.3.0
|
||||
|
@ -8,7 +8,7 @@ coveralls==1.2.0
|
||||
flake8-docstrings==1.3.0
|
||||
flake8==3.7.7
|
||||
mock-open==1.3.1
|
||||
mypy==0.670
|
||||
mypy==0.701
|
||||
pydocstyle==3.0.0
|
||||
pylint==2.3.1
|
||||
pytest-aiohttp==0.3.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user