
    wgJ)                         d Z ddlZddlZddlmZ  G d de      Z ej                  de       ddd	Zej                  d
        Z
y)z(
General SymPy exceptions and warnings.
    N)dedentc                   J     e Zd ZdZ fdZd Zd Zd Zed        Z	d Z
 xZS )SymPyDeprecationWarninga  
    A warning for deprecated features of SymPy.

    See the :ref:`deprecation-policy` document for details on when and how
    things should be deprecated in SymPy.

    Note that simply constructing this class will not cause a warning to be
    issued. To do that, you must call the :func`sympy_deprecation_warning`
    function. For this reason, it is not recommended to ever construct this
    class directly.

    Explanation
    ===========

    The ``SymPyDeprecationWarning`` class is a subclass of
    ``DeprecationWarning`` that is used for all deprecations in SymPy. A
    special subclass is used so that we can automatically augment the warning
    message with additional metadata about the version the deprecation was
    introduced in and a link to the documentation. This also allows users to
    explicitly filter deprecation warnings from SymPy using ``warnings``
    filters (see :ref:`silencing-sympy-deprecation-warnings`).

    Additionally, ``SymPyDeprecationWarning`` is enabled to be shown by
    default, unlike normal ``DeprecationWarning``\s, which are only shown by
    default in interactive sessions. This ensures that deprecation warnings in
    SymPy will actually be seen by users.

    See the documentation of :func:`sympy_deprecation_warning` for a
    description of the parameters to this function.

    To mark a function as deprecated, you can use the :func:`@deprecated
    <sympy.utilities.decorator.deprecated>` decorator.

    See Also
    ========
    sympy.utilities.exceptions.sympy_deprecation_warning
    sympy.utilities.exceptions.ignore_warnings
    sympy.utilities.decorator.deprecated
    sympy.testing.pytest.warns_deprecated_sympy

    c                   t         |   ||       || _        t        |t              st        d|      || _        | _        t        fddD              rt        d      dt        |      j                          d d| d| _        y )	Nz3'deprecated_since_version' should be a string, got c              3   &   K   | ]  }|v  
 y wN ).0iactive_deprecations_targets     _/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/utilities/exceptions.py	<genexpr>z3SymPyDeprecationWarning.__init__.<locals>.<genexpr>>   s     >1q..>s   z()=z=active_deprecations_target be the part inside of the '(...)='z

zI

See https://docs.sympy.org/latest/explanation/active-deprecations.html#z<
for details.

This has been deprecated since SymPy version z3. It
will be removed in a future version of SymPy.
)super__init__message
isinstancestr	TypeErrordeprecated_since_versionr   any
ValueErrorr   stripfull_message)selfr   r   r   	__class__s      `r   r   z SymPyDeprecationWarning.__init__5   s    ":/	12C8QRjQmnoo(@%*D'>>>\]]!  HHbGc d. /G-G H	    c                     | j                   S r   )r   r   s    r   __str__zSymPyDeprecationWarning.__str__L   s       r   c                     | j                   j                   d| j                  d| j                  d| j                  dS )N(z, deprecated_since_version=z, active_deprecations_target=))r   __name__r   r   r   r   s    r   __repr__z SymPyDeprecationWarning.__repr__O   sb    ..))*!DLL+;;VW[WtWtVw  xU  VZ  Vu  Vu  Ux  xy  z  	zr   c                 X    t        |t              xr | j                  |j                  k(  S r   )r   r   args)r   others     r   __eq__zSymPyDeprecationWarning.__eq__R   s"    %!89Udii5::>UUr   c                      | |||      S )Nr   r   r	   )clsr   r   r   s       r   _newzSymPyDeprecationWarning._newX   s     75M  kE  F  	Fr   c                 `    | j                   | j                  | j                  | j                  ffS r   )r,   r   r   r   r   s    r   
__reduce__z"SymPyDeprecationWarning.__reduce__]   s(    		DLL$*G*GIhIhijjr   )r#   
__module____qualname____doc__r   r   r$   r(   classmethodr,   r.   __classcell__)r   s   @r   r   r      s;    (R.!zV F Fkr   r   once   
stacklevelc                N    t        | ||      }t        j                  ||       y)a  
    Warn that a feature is deprecated in SymPy.

    See the :ref:`deprecation-policy` document for details on when and how
    things should be deprecated in SymPy.

    To mark an entire function or class as deprecated, you can use the
    :func:`@deprecated <sympy.utilities.decorator.deprecated>` decorator.

    Parameters
    ==========

    message : str
         The deprecation message. This may span multiple lines and contain
         code examples. Messages should be wrapped to 80 characters. The
         message is automatically dedented and leading and trailing whitespace
         stripped. Messages may include dynamic content based on the user
         input, but avoid using ``str(expression)`` if an expression can be
         arbitrary, as it might be huge and make the warning message
         unreadable.

    deprecated_since_version : str
         The version of SymPy the feature has been deprecated since. For new
         deprecations, this should be the version in `sympy/release.py
         <https://github.com/sympy/sympy/blob/master/sympy/release.py>`_
         without the ``.dev``. If the next SymPy version ends up being
         different from this, the release manager will need to update any
         ``SymPyDeprecationWarning``\s using the incorrect version. This
         argument is required and must be passed as a keyword argument.
         (example:  ``deprecated_since_version="1.10"``).

    active_deprecations_target : str
        The Sphinx target corresponding to the section for the deprecation in
        the :ref:`active-deprecations` document (see
        ``doc/src/explanation/active-deprecations.md``). This is used to
        automatically generate a URL to the page in the warning message. This
        argument is required and must be passed as a keyword argument.
        (example: ``active_deprecations_target="deprecated-feature-abc"``)

    stacklevel : int, default: 3
        The ``stacklevel`` parameter that is passed to ``warnings.warn``. If
        you create a wrapper that calls this function, this should be
        increased so that the warning message shows the user line of code that
        produced the warning. Note that in some cases there will be multiple
        possible different user code paths that could result in the warning.
        In that case, just choose the smallest common stacklevel.

    Examples
    ========

    >>> from sympy.utilities.exceptions import sympy_deprecation_warning
    >>> def is_this_zero(x, y=0):
    ...     """
    ...     Determine if x = 0.
    ...
    ...     Parameters
    ...     ==========
    ...
    ...     x : Expr
    ...       The expression to check.
    ...
    ...     y : Expr, optional
    ...       If provided, check if x = y.
    ...
    ...       .. deprecated:: 1.1
    ...
    ...          The ``y`` argument to ``is_this_zero`` is deprecated. Use
    ...          ``is_this_zero(x - y)`` instead.
    ...
    ...     """
    ...     from sympy import simplify
    ...
    ...     if y != 0:
    ...         sympy_deprecation_warning("""
    ...     The y argument to is_zero() is deprecated. Use is_zero(x - y) instead.""",
    ...             deprecated_since_version="1.1",
    ...             active_deprecations_target='is-this-zero-y-deprecation')
    ...     return simplify(x - y) == 0
    >>> is_this_zero(0)
    True
    >>> is_this_zero(1, 1) # doctest: +SKIP
    <stdin>:1: SymPyDeprecationWarning:
    <BLANKLINE>
    The y argument to is_zero() is deprecated. Use is_zero(x - y) instead.
    <BLANKLINE>
    See https://docs.sympy.org/latest/explanation/active-deprecations.html#is-this-zero-y-deprecation
    for details.
    <BLANKLINE>
    This has been deprecated since SymPy version 1.1. It
    will be removed in a future version of SymPy.
    <BLANKLINE>
      is_this_zero(1, 1)
    True

    See Also
    ========

    sympy.utilities.exceptions.SymPyDeprecationWarning
    sympy.utilities.exceptions.ignore_warnings
    sympy.utilities.decorator.deprecated
    sympy.testing.pytest.warns_deprecated_sympy

    r*   r6   N)r   warningswarn)r   r   r   r7   ws        r   sympy_deprecation_warningr<   c   s(    R 	 5M;U	WA MM!
+r   c              #   R  K   t        j                  d      5 }t        j                  d|        d ddd       D ]Y  }t        |j                  |       rt        j
                  |j                  |j                  |j                  |j                         [ y# 1 sw Y   hxY ww)ai  
    Context manager to suppress warnings during tests.

    .. note::

       Do not use this with SymPyDeprecationWarning in the tests.
       warns_deprecated_sympy() should be used instead.

    This function is useful for suppressing warnings during tests. The warns
    function should be used to assert that a warning is raised. The
    ignore_warnings function is useful in situation when the warning is not
    guaranteed to be raised (e.g. on importing a module) or if the warning
    comes from third-party code.

    This function is also useful to prevent the same or similar warnings from
    being issue twice due to recursive calls.

    When the warning is coming (reliably) from SymPy the warns function should
    be preferred to ignore_warnings.

    >>> from sympy.utilities.exceptions import ignore_warnings
    >>> import warnings

    Here's a warning:

    >>> with warnings.catch_warnings():  # reset warnings in doctest
    ...     warnings.simplefilter('error')
    ...     warnings.warn('deprecated', UserWarning)
    Traceback (most recent call last):
      ...
    UserWarning: deprecated

    Let's suppress it with ignore_warnings:

    >>> with warnings.catch_warnings():  # reset warnings in doctest
    ...     warnings.simplefilter('error')
    ...     with ignore_warnings(UserWarning):
    ...         warnings.warn('deprecated', UserWarning)

    (No warning emitted)

    See Also
    ========
    sympy.utilities.exceptions.SymPyDeprecationWarning
    sympy.utilities.exceptions.sympy_deprecation_warning
    sympy.utilities.decorator.deprecated
    sympy.testing.pytest.warns_deprecated_sympy

    T)recordalwaysN)	r9   catch_warningssimplefilter
issubclasscategorywarn_explicitr   filenamelineno)
warningclswarnrecr;   s      r   ignore_warningsrI      s     h 
	 	 	- h
3	  P!**j1""199ajj!**ahhOP s"   B'B#B'AB'B$ B')r1   r9   
contextlibtextwrapr   DeprecationWarningr   rA   r<   contextmanagerrI   r	   r   r   <module>rN      sf      Sk0 Skl   f5 6 FGl,^ <P <Pr   