From ae9d56e0fdd4df335a9def66aa2ac96459ed6e5c Mon Sep 17 00:00:00 2001 From: Yobmod Date: Thu, 24 Jun 2021 16:05:03 +0100 Subject: Make Iterable deprecation warning on subclassing --- git/util.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'git') diff --git a/git/util.py b/git/util.py index f72cd355..78a60c9a 100644 --- a/git/util.py +++ b/git/util.py @@ -1017,10 +1017,12 @@ class IterableList(List[T]): class IterableClassWatcher(type): def __init__(cls, name, bases, clsdict): for base in bases: - if type(base) == cls: - warnings.warn("GitPython Iterable is deprecated due to naming clash. Use IterableObj instead", - DeprecationWarning) - super(IterableClassWatcher, cls).__init__(name, bases, clsdict) + if type(base) == IterableClassWatcher: + warnings.warn(f"GitPython Iterable subclassed by {name}. " + "Iterable is deprecated due to naming clash, " + "Use IterableObj instead \n", + DeprecationWarning, + stacklevel=2) class Iterable(object): -- cgit v1.2.1