Skip to content

Commit

Permalink
re-add Function
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Nov 4, 2024
1 parent bcacdaf commit d2b376e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion basedtyping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"FunctionType",
"TCallable",
"TFunction",
"Function",
"T",
"in_T",
"out_T",
Expand Down Expand Up @@ -109,6 +110,20 @@ def __rand__(self, other: object) -> object:
return Intersection[other, self]


if TYPE_CHECKING:
Function = Callable[..., object] # type: ignore[no-any-explicit]
"""deprecated, use `AnyCallable`/`AnyFunction` instead. Any ``Callable``.
useful when using mypy with ``disallow-any-explicit``
due to https://github.com/python/mypy/issues/9496
Cannot actually be called unless it's narrowed, so it should only really be used as
a bound in a ``TypeVar``.
"""
else:
# for isinstance checks
Function = Callable

# Unlike the generics in other modules, these are meant to be imported to save you
# from the boilerplate
T = TypeVar("T")
Expand Down Expand Up @@ -137,7 +152,7 @@ def __rand__(self, other: object) -> object:
TCallable = TypeVar("TCallable", bound=AnyCallable)
TFunction = TypeVar("TFunction", bound=AnyFunction)
Fn = TypeVar("Fn", bound=AnyCallable)
"""this is deprecated, use `TCallable` or `TFunction` instead"""
"""deprecated, use `TCallable` or `TFunction` instead"""


def _type_convert(arg: object) -> object:
Expand Down

0 comments on commit d2b376e

Please sign in to comment.