Skip to content

Commit 2824f1f

Browse files
committed
cleanup
1 parent 5bd6b77 commit 2824f1f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sphinx/util/typing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ def restify(cls: type | None, mode: str = 'fully-qualified-except-typing') -> st
182182
return f':py:class:`{modprefix}{cls.__name__}`'
183183
elif ismock(cls):
184184
return f':py:class:`{modprefix}{cls.__module__}.{cls.__name__}`'
185-
elif is_invalid_builtin_class(cls): # this never raises TypeError
185+
elif is_invalid_builtin_class(cls):
186+
# The above predicate never raises TypeError but should not be
187+
# evaluated before determining whether *cls* is a mocked object
188+
# or not; instead of two try-except blocks, we keep it here.
186189
return f':py:class:`{modprefix}{_INVALID_BUILTIN_CLASSES[cls]}`'
187190
elif inspect.isNewType(cls):
188191
if sys.version_info[:2] >= (3, 10):

0 commit comments

Comments
 (0)