from qiskit.utils.deprecation import deprecate_function
from qiskit.utils.deprecation import deprecate_arguments

class DummyClass:
    """This is short description. Let's make it
    multiline"""

    def __init__(self, arg1: int = None, arg2: [int] = None):
        self.arg1 = arg1
        self.arg2 = arg2

    @deprecate_function(
        "The DummyClass.foo() method is being deprecated. Use the DummyClass.some_othermethod()",
        since="1.2.3",
    )
    def foo_deprecated(self, index_arg2: int):
        """A multi-line
        docstring.

        Here are more details.

        Args:
            index_arg2: `index_arg2` description

        Returns:
            int: returns `arg2[index_arg2]`

        Raises:
            QiskitError: if `len(self.arg2) < index_arg2`
        """
        if len(self.arg2) < index_arg2:
            raise QiskitError("there is an error")
        return self.arg2[index_arg2]

    @deprecate_arguments({"if_arg1": "other_if_arg1"}, since="1.2.3")
    def bar_with_deprecated_arg(
        self, if_arg1: int = None, index_arg2: int = None, other_if_arg1: int = None
    ):
        """
        A multi-line short
        docstring.

        This is the long description

        Args:
            if_arg1: `if_arg1` description with
               multi-line
            index_arg2: `index_arg2` description
            other_if_arg1: `other_if_arg1` description

        Returns:
            int or None: if `if_arg1 == self.arg1`, returns `arg2[index_arg2]`
        """
        if other_if_arg1 == self.arg1 or if_arg1 == self.arg1:
            return self.arg2[index_arg2]
        return None

d = DummyClass(1, [1,2])

d.foo_deprecated(0)

print(d.foo_deprecated.__doc__)

d.bar_with_deprecated_arg(if_arg1=0)

d.bar_with_deprecated_arg(other_if_arg1=0)

print(d.bar_with_deprecated_arg.__doc__)

def f():
    """Normal docstring"""
    pass
deprecate_function("deprecation message", since="1.2.3")(f)
print(f.__doc__)

def f():
    """Normal docstring"""
    pass
deprecate_function("deprecation message", modify_docstring=False, since="1.2.3")(f)
print(f.__doc__)

def f():
    """Normal docstring"""
    pass
deprecate_function("deprecation message", modify_docstring=True)(f)
print(f.__doc__)

from qiskit import __version__

def f():
    """Normal docstring"""
    pass
deprecate_function("deprecation message", modify_docstring=True, since=__version__)(f)
print(f.__doc__)

