Skip to content

Commit 8258353

Browse files
committed
Simplify the metaclass
No reason to look up __deepcopy__ in base classes.
1 parent 990ffdf commit 8258353

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

lib/matplotlib/path.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,14 @@
2525
class _HideDeepcopyMeta(type):
2626
"""Metaclass that allows conditionally hiding the __deepcopy__ method.
2727
28-
Set __hide_deepcopy__ to True to hide the __deepcopy__ method,
29-
which will then be looked up in the usual method resolution order.
28+
Set __hide_deepcopy__ to True to hide the __deepcopy__ method.
3029
"""
3130

3231
def __new__(cls, name, bases, namespace):
3332
orig_ga = namespace.get("__getattribute__") or object.__getattribute__
3433

3534
def __getattribute__(self, attr_name):
3635
if attr_name == "__deepcopy__" and orig_ga(self, "__hide_deepcopy__"):
37-
for base in type(self).__mro__[1:]:
38-
if attr_name in base.__dict__:
39-
method = base.__dict__[attr_name]
40-
return method.__get__(self, type(self))
4136
raise AttributeError(
4237
f"'{type(self).__name__}' object has no attribute '{attr_name}'"
4338
)

0 commit comments

Comments
 (0)