Improve typing [util.location] (#70893)

This commit is contained in:
Marc Mueller 2022-04-27 17:20:56 +02:00 committed by GitHub
parent 964c764dae
commit 02ddfd513a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 18 deletions

View File

@ -25,6 +25,7 @@ homeassistant.helpers.translation
homeassistant.util.async_
homeassistant.util.color
homeassistant.util.decorator
homeassistant.util.location
homeassistant.util.process
homeassistant.util.unit_system

View File

@ -6,9 +6,8 @@ detect_location_info and elevation are mocked by default during tests.
from __future__ import annotations
import asyncio
import collections
import math
from typing import Any
from typing import Any, NamedTuple
import aiohttp
@ -30,22 +29,21 @@ MILES_PER_KILOMETER = 0.621371
MAX_ITERATIONS = 200
CONVERGENCE_THRESHOLD = 1e-12
LocationInfo = collections.namedtuple(
"LocationInfo",
[
"ip",
"country_code",
"currency",
"region_code",
"region_name",
"city",
"zip_code",
"time_zone",
"latitude",
"longitude",
"use_metric",
],
)
class LocationInfo(NamedTuple):
"""Tuple with location information."""
ip: str
country_code: str
currency: str
region_code: str
region_name: str
city: str
zip_code: str
time_zone: str
latitude: float
longitude: float
use_metric: bool
async def async_detect_location_info(

View File

@ -86,6 +86,9 @@ disallow_any_generics = true
[mypy-homeassistant.util.decorator]
disallow_any_generics = true
[mypy-homeassistant.util.location]
disallow_any_generics = true
[mypy-homeassistant.util.process]
disallow_any_generics = true