summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-06-24 16:05:03 +0100
committerYobmod <yobmod@gmail.com>2021-06-24 16:05:03 +0100
commitae9d56e0fdd4df335a9def66aa2ac96459ed6e5c (patch)
tree4e95390d3b8606602401bbec049b029450453f3b
parent3cef949913659584dd980f3de363dd830392bb68 (diff)
downloadgitpython-ae9d56e0fdd4df335a9def66aa2ac96459ed6e5c.tar.gz
Make Iterable deprecation warning on subclassing
-rw-r--r--git/util.py10
-rw-r--r--t.py13
2 files changed, 17 insertions, 6 deletions
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):
diff --git a/t.py b/t.py
index 05d59c0c..215c2667 100644
--- a/t.py
+++ b/t.py
@@ -1,7 +1,15 @@
+import warnings
+
+
class Watcher(type):
def __init__(cls, name, bases, clsdict):
- [print("ooooo") for base in bases if issubclass(base, name)]
- super(Watcher, cls).__init__(name, bases, clsdict)
+ for base in bases:
+ if type(base) == Watcher:
+ warnings.warn(f"GitPython Iterable subclassed by {name}. "
+ "Iterable is deprecated due to naming clash, "
+ "Use IterableObj instead \n",
+ DeprecationWarning,
+ stacklevel=2)
class SuperClass(metaclass=Watcher):
@@ -15,5 +23,6 @@ class SubClass0(SuperClass):
class SubClass1(SuperClass):
print("test")
+
class normo():
print("wooo")