Skip to content

Commit 3a567f0

Browse files
authored
Use module and method descriptor types declared in the types module (#14055)
Fixes #14041.
2 parents b518e6a + 600d3cd commit 3a567f0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

IPython/core/guarded_eval.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919
from functools import cached_property
2020
from dataclasses import dataclass, field
21+
from types import MethodDescriptorType, ModuleType
2122

2223
from IPython.utils.docs import GENERATING_DOCUMENTATION
2324
from IPython.utils.decorators import undoc
@@ -630,8 +631,6 @@ def _list_methods(cls, source=None):
630631

631632

632633
dict_keys: Type[collections.abc.KeysView] = type({}.keys())
633-
method_descriptor: Any = type(list.copy)
634-
module = type(builtins)
635634

636635
NUMERICS = {int, float, complex}
637636

@@ -680,8 +679,8 @@ def _list_methods(cls, source=None):
680679
type, # `type` handles a lot of generic cases, e.g. numbers as in `int.real`.
681680
*NUMERICS,
682681
dict_keys,
683-
method_descriptor,
684-
module,
682+
MethodDescriptorType,
683+
ModuleType,
685684
}
686685

687686

0 commit comments

Comments
 (0)