summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Stepanov <penguinolog@users.noreply.github.com>2023-04-18 18:57:39 +0200
committerGitHub <noreply@github.com>2023-04-18 18:57:39 +0200
commit50e763194c56b1ef11d16d7c2cd24f66639fa049 (patch)
tree8112e9146aeefbb7a269f52ca484227c05f37216
parent46f104b5b4fa22ccb04ba0f04be24bb7c4f7f7fe (diff)
downloadurwid-50e763194c56b1ef11d16d7c2cd24f66639fa049.tar.gz
Deprecate `__super` hack (#538)
* Deprecate `__super` hack `super()` should be called explicit * Update urwid/util.py Co-authored-by: Ian Ward <ian@excess.org> --------- Co-authored-by: Aleksei Stepanov <alekseis@nvidia.com> Co-authored-by: Ian Ward <ian@excess.org>
-rw-r--r--urwid/util.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/urwid/util.py b/urwid/util.py
index fa2f907..13094fb 100644
--- a/urwid/util.py
+++ b/urwid/util.py
@@ -24,6 +24,7 @@ from __future__ import annotations
import codecs
import typing
+import warnings
from urwid import escape
@@ -445,7 +446,17 @@ class MetaSuper(type):
super().__init__(name, bases, d)
if hasattr(cls, f"_{name}__super"):
raise AttributeError("Class has same name as one of its super classes")
- setattr(cls, f"_{name}__super", super(cls))
+
+ @property
+ def _super(self):
+ warnings.warn(
+ f"`{name}.__super` was a deprecated feature for old python versions."
+ f"Please use `super()` call instead.",
+ DeprecationWarning,
+ stacklevel=3,
+ )
+ return super(cls, self)
+ setattr(cls, f"_{name}__super", _super)
def int_scale(val: int, val_range: int, out_range: int):