Skip to content

Commit df6439f

Browse files
committed
re-add Function
1 parent bcacdaf commit df6439f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

basedtyping/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"FunctionType",
5555
"TCallable",
5656
"TFunction",
57+
"Function",
5758
"T",
5859
"in_T",
5960
"out_T",
@@ -109,6 +110,20 @@ def __rand__(self, other: object) -> object:
109110
return Intersection[other, self]
110111

111112

113+
if TYPE_CHECKING:
114+
Function = Callable[..., object] # type: ignore[no-any-explicit]
115+
"""deprecated, use `AnyCallable`/`AnyFunction` instead. Any ``Callable``.
116+
117+
useful when using mypy with ``disallow-any-explicit``
118+
due to https://github.com/python/mypy/issues/9496
119+
120+
Cannot actually be called unless it's narrowed, so it should only really be used as
121+
a bound in a ``TypeVar``.
122+
"""
123+
else:
124+
# for isinstance checks
125+
Function = Callable
126+
112127
# Unlike the generics in other modules, these are meant to be imported to save you
113128
# from the boilerplate
114129
T = TypeVar("T")
@@ -137,7 +152,7 @@ def __rand__(self, other: object) -> object:
137152
TCallable = TypeVar("TCallable", bound=AnyCallable)
138153
TFunction = TypeVar("TFunction", bound=AnyFunction)
139154
Fn = TypeVar("Fn", bound=AnyCallable)
140-
"""this is deprecated, use `TCallable` or `TFunction` instead"""
155+
"""deprecated, use `TCallable` or `TFunction` instead"""
141156

142157

143158
def _type_convert(arg: object) -> object:

0 commit comments

Comments
 (0)