mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Update typing syntax (#49480)
* Update typing syntax * Replace typing imports with ones from collections where possible * Changes after review
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Helpers for config validation using voluptuous."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Hashable
|
||||
from datetime import (
|
||||
date as date_sys,
|
||||
datetime as datetime_sys,
|
||||
@@ -14,7 +15,7 @@ from numbers import Number
|
||||
import os
|
||||
import re
|
||||
from socket import _GLOBAL_DEFAULT_TIMEOUT # type: ignore # private, not in typeshed
|
||||
from typing import Any, Callable, Dict, Hashable, Pattern, TypeVar, cast
|
||||
from typing import Any, Callable, Dict, TypeVar, cast
|
||||
from urllib.parse import urlparse
|
||||
from uuid import UUID
|
||||
|
||||
@@ -204,7 +205,7 @@ def matches_regex(regex: str) -> Callable[[Any], str]:
|
||||
return validator
|
||||
|
||||
|
||||
def is_regex(value: Any) -> Pattern[Any]:
|
||||
def is_regex(value: Any) -> re.Pattern[Any]:
|
||||
"""Validate that a string is a valid regular expression."""
|
||||
try:
|
||||
r = re.compile(value)
|
||||
|
||||
Reference in New Issue
Block a user