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.async_
homeassistant.util.color homeassistant.util.color
homeassistant.util.decorator homeassistant.util.decorator
homeassistant.util.location
homeassistant.util.process homeassistant.util.process
homeassistant.util.unit_system 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 from __future__ import annotations
import asyncio import asyncio
import collections
import math import math
from typing import Any from typing import Any, NamedTuple
import aiohttp import aiohttp
@ -30,22 +29,21 @@ MILES_PER_KILOMETER = 0.621371
MAX_ITERATIONS = 200 MAX_ITERATIONS = 200
CONVERGENCE_THRESHOLD = 1e-12 CONVERGENCE_THRESHOLD = 1e-12
LocationInfo = collections.namedtuple(
"LocationInfo", class LocationInfo(NamedTuple):
[ """Tuple with location information."""
"ip",
"country_code", ip: str
"currency", country_code: str
"region_code", currency: str
"region_name", region_code: str
"city", region_name: str
"zip_code", city: str
"time_zone", zip_code: str
"latitude", time_zone: str
"longitude", latitude: float
"use_metric", longitude: float
], use_metric: bool
)
async def async_detect_location_info( async def async_detect_location_info(

View File

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