diff --git a/mypy/nodes.py b/mypy/nodes.py index edf8a5c5c7f76..1dfd70267b06a 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -4059,11 +4059,11 @@ def get_method(self, name: str) -> FuncBase | Decorator | None: for cls in self.mro: sym = cls.names.get(name) if sym is None: - # add_redefinition installs the unnumbered name before any numbered ones. - prefix = f"{name}-redefinition" - if prefix not in cls.names: + # Plugins are allowed to meddle with redefinitions (first one wins). + if cls.metadata: + sym = cls.names.get(f"{name}-redefinition") + if sym is None: continue - sym = cls.names[max(n for n in cls.names if n.startswith(prefix))] node = sym.node if isinstance(node, SYMBOL_FUNCBASE_TYPES): return node