Git Product home page Git Product logo

deprecat's People

Contributors

cclauss avatar dhodovsk avatar heidecjj avatar hugovk avatar jpopelka avatar mariusvniekerk avatar mgorny avatar mhendricks avatar mjhajharia avatar phracek avatar santosh653 avatar soxofaan avatar tantale avatar vrcmarcos avatar yarikoptic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

arpitjain799

deprecat's Issues

Add google docstring format

Minimal version of the idea is to have a kwarg in the sphinx decorator that lets you choose the kind of docstrings you have with args being numpydoc, google. Currently, only Numpydoc is supported as it is more common in a lot of open source software, but sphinx supports google docstrings as well.

You'd only want to change the regex for finding the position in the docstring.

Autogenerate the docstring examples

There is a https://deprecat.readthedocs.io/en/latest/source/usage.html#docstring section which is hardcoded in rST instead of showing the actual output.

I would try to create a showcase module inside the library that is not used by it nor exposed when imported but has one example of each deprecation type, class, function, method, kwarg... and then create a showcase api docs. I think this will serve also as a rudimentary test that the output looks as desired when doing changes in a way that automated tests can't

Update tests

All the tests are unmodified and taken as it is from github:tantale/deprecated, we need to change them to suit the new features such as deprecated_args

Decorator breaks when there's no "Parameters" section in the docstring

On a method that doesn't have a docstring at all, or is missing the expected section, the search result is None:

search = re.search("Parameters[\s]*\n[\s]*----------", docstring)
params_string = docstring[search.start():search.end()]

Traceback

...\deprecat\classic.py:217: in deprecat
    return wrapper_function(wrapped)
...\wrapt\decorators.py:417: in _wrapper
    return _build(target_wrapped, target_wrapper, _enabled, adapter)
...\wrapt\decorators.py:207: in _build
    adapter = adapter(wrapped)
...\deprecat\sphinx.py:145: in __call__
    params_string = docstring[search.start():search.end()]
E   AttributeError: 'NoneType' object has no attribute 'start'

Feature Request: "Will be removed in" version number

In addition to version= giving the "deprecated in" version number, it would be nice to be able to specify a "will be removed in" version number.

You could add another argument, e.g. say with remove_version or deadline_version.

I can do a PR if nobody who knows the code better has the time.

Permits the use of an empty reason

As a way to keep the verbosity to minimum (in log and in the code), I think this would be nice to be able to left the "reason" empty (e.g., if the reason is too obvious or too long).

@deprecat(deprecated_args={'a':{'version':'4.0'}, 'b':{'version':'3.0'}})
def multiply(a, b, c):
    return 42

Currently the code above raises an error:

Traceback (most recent call last):
File "", line 1, in
File "/opt/homebrew/lib/python3.11/site-packages/deprecat/classic.py", line 205, in wrapper_function
msg = adapter.get_deprecated_msg(wrapped_, instance_, kwargs_)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/deprecat/classic.py", line 120, in get_deprecated_msg
if self.deprecated_args[arg]['reason']:
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^

While, IMO, it would be great to show

>>> multiply(a=1,b=2,c=3)
:1: DeprecationWarning: Call to deprecated Parameter a. -- Deprecated since v4.0.
:1: DeprecationWarning: Call to deprecated Parameter b. -- Deprecated since v3.0.
42

If needed, I'd be happy to help and implement this feature.

Raise the deprecation warning for args (besides kwargs)

Currently the deprecation warning is only shown for kwargs. I think that doing the same for args would be interesting (either by config or by default).

@deprecat(deprecated_args={'a':{'version':'4.0', 'reason': ''}, 'b':{'version':'3.0',  'reason': ''}})
def multiply(a, b, c):
    return 42
    
multiply(1,2,3)
multiply(a=1,b=2,c=3)

Wouldn't it be more consistent to display the deprecation at the first call? The deprecated args have actually been called. Currently the output is

>>> multiply(1,2,3)
42
>>> multiply(a=1,b=2,c=3)
<stdin>:1: DeprecationWarning: Call to deprecated Parameter a. -- Deprecated since v4.0.
<stdin>:1: DeprecationWarning: Call to deprecated Parameter b. -- Deprecated since v3.0.
42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.