When an object has an attribute that shares the same name a method on the object's class (or another class attribute), the instance attribute is prioritized during attribute lookup, shadowing the method. If a method on a subclass is shadowed by an attribute on a superclass in this way, this may lead to unexpected results or errors, as this shadowing behavior is nonlocal and may be unintended.

Ensure method names on subclasses don't conflict with attribute names on superclasses, and rename one. If the shadowing behavior is intended, ensure this is explicit in the superclass.

In the following example, the _foo attribute of class A shadows the method _foo of class B. Calls to B()._foo() will result in a TypeError, as 3 will be called instead.

In the following example, the behavior of the default attribute being shadowed to allow for customization during initialization is intended in within the superclass A. Overriding default in the subclass B is then OK.