Skip to content

Commit 01bd1a2

Browse files
committed
Don't treat functions with reversible dunder names as such
Previously, functions that had the same name as a reversible dunder method (for example, __rpow__) were checked as if they were such a method. This could lead to crashes and false positives. Closes: python#5419
1 parent 3eae0a9 commit 01bd1a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypy/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ def check_func_def(self, defn: FuncItem, typ: CallableType, name: Optional[str])
775775
self.msg, context=fdef)
776776

777777
if name: # Special method names
778-
if name in nodes.reverse_op_method_set:
778+
if defn.info and name in nodes.reverse_op_method_set:
779779
self.check_reverse_op_method(item, typ, name, defn)
780780
elif name in ('__getattr__', '__getattribute__'):
781781
self.check_getattr_method(typ, defn, name)

0 commit comments

Comments
 (0)