Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify
  • Loading branch information
AlexWaygood committed May 31, 2023
commit 3b56274c3d6a846ceaf02145ab89f44190cd6e3b
6 changes: 3 additions & 3 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ def _caller(depth=1, default='__main__'):
pass
return None

def _allow_reckless_class_checks(depth=3):
def _allow_reckless_class_checks(depth=2):
"""Allow instance and class checks for special stdlib modules.

The abc and functools modules indiscriminately call isinstance() and
Expand Down Expand Up @@ -1787,7 +1787,7 @@ def __subclasscheck__(cls, other):
raise TypeError('issubclass() arg 1 must be a class')
if (
getattr(cls, '_is_protocol', False)
and not _allow_reckless_class_checks(depth=2)
and not _allow_reckless_class_checks()
):
if not cls.__callable_proto_members_only__:
raise TypeError(
Expand All @@ -1809,7 +1809,7 @@ def __instancecheck__(cls, instance):

if (
not getattr(cls, '_is_runtime_protocol', False) and
not _allow_reckless_class_checks(depth=2)
not _allow_reckless_class_checks()
):
raise TypeError("Instance and class checks can only be used with"
" @runtime_checkable protocols")
Expand Down