Skip to content

Permits the use of an empty reason #15

@loicvh

Description

@loicvh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions