Skip to content

Raise the deprecation warning for args (besides kwargs) #16

@loicvh

Description

@loicvh

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

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