From 21384c3da92708760f7049beb1ae2258679e2fd1 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 22 Feb 2024 11:25:12 -0500 Subject: [PATCH] chore: resurrect `SupportsSchema` type; clean up unused ignored imports (#8421) --- ibis/common/typing.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ibis/common/typing.py b/ibis/common/typing.py index 255939c96aad..5d4bca1d1678 100644 --- a/ibis/common/typing.py +++ b/ibis/common/typing.py @@ -4,25 +4,27 @@ import sys from abc import abstractmethod from itertools import zip_longest -from types import ModuleType # noqa: F401 -from typing import ( - TYPE_CHECKING, - Any, - Generic, # noqa: F401 - Optional, - TypeVar, - Union, - get_args, - get_origin, -) +from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union, get_args, get_origin from typing import get_type_hints as _get_type_hints from ibis.common.bases import Abstract from ibis.common.caching import memoize if TYPE_CHECKING: + from collections.abc import Iterable, Mapping + from typing_extensions import Self + import ibis.expr.datatypes as dt + import ibis.expr.schema as sch + + SupportsSchema = TypeVar( + "SupportsSchema", + sch.Schema, + Mapping[str, str | dt.DataType], + Iterable[tuple[str, str | dt.DataType]], + ) + if sys.version_info >= (3, 10): from types import UnionType from typing import TypeAlias @@ -144,6 +146,7 @@ def get_bound_typevars(obj: Any) -> dict[TypeVar, tuple[str, type]]: Examples -------- + >>> from typing import Generic >>> class MyStruct(Generic[T, U]): ... a: T ... b: U