diff --git a/mypy/checker.py b/mypy/checker.py index dbd1adfb42e3..310058b07bc6 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -70,6 +70,7 @@ LDEF, LITERAL_TYPE, MDEF, + SYMBOL_FUNCBASE_TYPES, AssertStmt, AssignmentExpr, AssignmentStmt, @@ -2292,7 +2293,7 @@ def check_multiple_inheritance(self, typ: TypeInfo) -> None: def determine_type_of_member(self, sym: SymbolTableNode) -> Type | None: if sym.type is not None: return sym.type - if isinstance(sym.node, FuncBase): + if isinstance(sym.node, SYMBOL_FUNCBASE_TYPES): return self.function_type(sym.node) if isinstance(sym.node, TypeInfo): if sym.node.typeddict_type: diff --git a/mypy/checkmember.py b/mypy/checkmember.py index 5acef28310fb..6b5ae74c04a0 100644 --- a/mypy/checkmember.py +++ b/mypy/checkmember.py @@ -951,7 +951,7 @@ def analyze_class_attribute_access( t = erase_typevars(expand_type_by_instance(t, isuper)) is_classmethod = (is_decorated and cast(Decorator, node.node).func.is_class) or ( - isinstance(node.node, FuncBase) and node.node.is_class + isinstance(node.node, SYMBOL_FUNCBASE_TYPES) and node.node.is_class ) t = get_proper_type(t) if isinstance(t, FunctionLike) and is_classmethod: @@ -993,7 +993,7 @@ def analyze_class_attribute_access( mx.not_ready_callback(name, mx.context) return AnyType(TypeOfAny.from_error) else: - assert isinstance(node.node, FuncBase) + assert isinstance(node.node, SYMBOL_FUNCBASE_TYPES) typ = function_type(node.node, mx.named_type("builtins.function")) # Note: if we are accessing class method on class object, the cls argument is bound. # Annotated and/or explicit class methods go through other code paths above, for @@ -1226,7 +1226,7 @@ def is_valid_constructor(n: SymbolNode | None) -> bool: This includes normal functions, overloaded functions, and decorators that return a callable type. """ - if isinstance(n, FuncBase): + if isinstance(n, SYMBOL_FUNCBASE_TYPES): return True if isinstance(n, Decorator): return isinstance(get_proper_type(n.type), FunctionLike) diff --git a/mypy/nodes.py b/mypy/nodes.py index 98fa54c0cd36..996cce3aef8c 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -2936,7 +2936,7 @@ def get_method(self, name: str) -> FuncBase | Decorator | None: for cls in self.mro: if name in cls.names: node = cls.names[name].node - if isinstance(node, FuncBase): + if isinstance(node, SYMBOL_FUNCBASE_TYPES): return node elif isinstance(node, Decorator): # Two `if`s make `mypyc` happy return node diff --git a/mypy/server/astdiff.py b/mypy/server/astdiff.py index 815e2ca281eb..fcdca1d41b11 100644 --- a/mypy/server/astdiff.py +++ b/mypy/server/astdiff.py @@ -57,9 +57,9 @@ class level -- these are handled at attribute level (say, 'mod.Cls.method' from mypy.expandtype import expand_type from mypy.nodes import ( + SYMBOL_FUNCBASE_TYPES, UNBOUND_IMPORTED, Decorator, - FuncBase, FuncItem, MypyFile, OverloadedFuncDef, @@ -211,7 +211,7 @@ def snapshot_definition(node: SymbolNode | None, common: tuple[object, ...]) -> The representation is nested tuples and dicts. Only externally visible attributes are included. """ - if isinstance(node, FuncBase): + if isinstance(node, SYMBOL_FUNCBASE_TYPES): # TODO: info if node.type: signature = snapshot_type(node.type) diff --git a/mypy/server/deps.py b/mypy/server/deps.py index 45d7947641da..437f3a35fd42 100644 --- a/mypy/server/deps.py +++ b/mypy/server/deps.py @@ -88,6 +88,7 @@ class 'mod.Cls'. This can also refer to an attribute inherited from a GDEF, LDEF, MDEF, + SYMBOL_FUNCBASE_TYPES, AssertTypeExpr, AssignmentStmt, AwaitExpr, @@ -506,7 +507,7 @@ def visit_assignment_stmt(self, o: AssignmentStmt) -> None: if isinstance(rvalue.callee.node, TypeInfo): # use actual __init__ as a dependency source init = rvalue.callee.node.get("__init__") - if init and isinstance(init.node, FuncBase): + if init and isinstance(init.node, SYMBOL_FUNCBASE_TYPES): fname = init.node.fullname else: fname = rvalue.callee.fullname