mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Make typing checks more strict (#14429)
## Description: Make typing checks more strict: add `--strict-optional` flag that forbids implicit None return type. This flag will become default in the next version of mypy (0.600) Add `homeassistant/util/` to checked dirs. ## Checklist: - [x] The code change is tested and works locally. - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
This commit is contained in:
@@ -86,11 +86,11 @@ class UnitSystem(object):
|
||||
self.volume_unit = volume
|
||||
|
||||
@property
|
||||
def is_metric(self: object) -> bool:
|
||||
def is_metric(self) -> bool:
|
||||
"""Determine if this is the metric unit system."""
|
||||
return self.name == CONF_UNIT_SYSTEM_METRIC
|
||||
|
||||
def temperature(self: object, temperature: float, from_unit: str) -> float:
|
||||
def temperature(self, temperature: float, from_unit: str) -> float:
|
||||
"""Convert the given temperature to this unit system."""
|
||||
if not isinstance(temperature, Number):
|
||||
raise TypeError(
|
||||
@@ -99,7 +99,7 @@ class UnitSystem(object):
|
||||
return temperature_util.convert(temperature,
|
||||
from_unit, self.temperature_unit)
|
||||
|
||||
def length(self: object, length: float, from_unit: str) -> float:
|
||||
def length(self, length: float, from_unit: str) -> float:
|
||||
"""Convert the given length to this unit system."""
|
||||
if not isinstance(length, Number):
|
||||
raise TypeError('{} is not a numeric value.'.format(str(length)))
|
||||
|
||||
Reference in New Issue
Block a user