laurent-laporte-pro / deprecated

Python @deprecated decorator to deprecate old python classes, functions or methods.
MIT License
307 stars 34 forks source link

versionadded emit DeprecationWarning during pytest #34

Closed rino0601 closed 3 years ago

rino0601 commented 3 years ago

According to the this example versionadded should not emit the warning, but when I run the test code it does.

Expected Behavior

from deprecated.sphinx import versionadded

class Macros(object):

    class Macro(object):
        def __call__(self, *args,**kwargs):
            ... 

    @versionadded(version='0.7.0')
    class HiveDatabase(Macro):
        ...

I expected this will work fine

Actual Behavior

when I run pytest...

tests/context/test_macros.py: 12 tests with warnings
  /Users/user/IdeaProjects/airsflow/airsflow/context/macros.py:58: DeprecationWarning: Call to deprecated class HiveDatabase. -- Deprecated since version 0.7.0.
    return cls(ctx, *args, namespace=namespace, context=context, **kwargs)

Environment

tantale commented 3 years ago

Hello,

I confirm that this is an issue with versionadded and versionchanged.

The Sphinx adapter shouldn't call the base class wrapper for this kind of directives to avoid the warning.

Can you make a PR with an unit test (or fix the existing unit tests)?

Regards