File: _utils.py

package info (click to toggle)
python-anyqt 0.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 560 kB
  • sloc: python: 4,087; makefile: 192; sh: 3
file content (26 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import warnings


def obsolete_rename(oldname, newfunc):
    """
    Simple obsolete/removed method decorator

    Parameters
    ----------
    oldname : str
        The name of the old obsolete name
    newfunc : FunctionType
        Replacement unbound member function.
    """
    newname = newfunc.__name__
    def __obsolete(*args, **kwargs):
        warnings.warn(
            "{oldname} is obsolete and is removed in PyQt5. "
            "Use {newname} instead.".format(oldname=oldname, newname=newname),
            DeprecationWarning,
            stacklevel=2
        )
        return newfunc(*args, **kwargs)
    __obsolete.__name__ = oldname
    return __obsolete