Skip to content

Commit 9e6a597

Browse files
committed
Python 3.13: bool can now be casted to Callable[[Any * N], Any]
References #15
1 parent e281951 commit 9e6a597

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -1354,9 +1354,12 @@ def test_callable_p_r(self) -> None:
13541354
self.assertTryCastFailure(Callable[[], Any], _CallableObjectWithOneArg()) # type: ignore[6] # pyre
13551355
self.assertTryCastFailure(Callable[[], Any], _TypeWithOneArgConstructor) # type: ignore[6] # pyre
13561356

1357-
# NOTE: Cannot introspect constructor for certain built-in types
1358-
# TODO: Define __signature__ for failing internal types
1359-
self.assertTryCastFailure(Callable[[], Any], bool) # type: ignore[6] # pyre
1357+
# NOTE: Cannot introspect constructor for certain built-in types lacking __signature__.
1358+
# See: https://github.com/davidfstr/trycast/issues/15
1359+
if sys.version_info >= (3, 13):
1360+
self.assertTryCastSuccess(Callable[[], Any], bool) # type: ignore[6] # pyre
1361+
else:
1362+
self.assertTryCastFailure(Callable[[], Any], bool) # type: ignore[6] # pyre
13601363
self.assertTryCastFailure(Callable[[], Any], int) # type: ignore[6] # pyre
13611364
self.assertTryCastSuccess(Callable[[], Any], float) # type: ignore[6] # pyre
13621365
self.assertTryCastSuccess(Callable[[], Any], complex) # type: ignore[6] # pyre
@@ -1380,9 +1383,12 @@ def test_callable_p_r(self) -> None:
13801383
)
13811384
self.assertTryCastFailure(Callable[[Any], Any], _TypeWithZeroArgConstructor) # type: ignore[6] # pyre
13821385

1383-
# NOTE: Cannot introspect constructor for certain built-in types
1384-
# TODO: Define __signature__ for failing internal types
1385-
self.assertTryCastFailure(Callable[[Any], Any], bool) # type: ignore[6] # pyre
1386+
# NOTE: Cannot introspect constructor for certain built-in types lacking __signature__.
1387+
# See: https://github.com/davidfstr/trycast/issues/15
1388+
if sys.version_info >= (3, 13):
1389+
self.assertTryCastSuccess(Callable[[Any], Any], bool) # type: ignore[6] # pyre
1390+
else:
1391+
self.assertTryCastFailure(Callable[[Any], Any], bool) # type: ignore[6] # pyre
13861392
self.assertTryCastFailure(Callable[[Any], Any], int) # type: ignore[6] # pyre
13871393
self.assertTryCastSuccess(Callable[[Any], Any], float) # type: ignore[6] # pyre
13881394
self.assertTryCastSuccess(Callable[[Any], Any], complex) # type: ignore[6] # pyre

0 commit comments

Comments
 (0)