Skip to main content

A Wrapper for functions, class objects and methods for deprecating keyword parameters

Project description

Deprecated Params

Inspired after python's warning.deprecated wrapper, deprecated_params is made to serve the single purpose of deprecating parameter names to warn users about incoming changes as well as retaining typehinting.

How to Deprecate Parameters

Parameters should be keyword arguments, not positional, Reason for this implementation is that in theory you should've already planned an alternative approch to an argument you wish to deprecate.

from deprecated_params import deprecated_params

@deprecated_params(['x'])
def func(y, *, x:int = 0):
    pass

# DeprecationWarning: Parameter "x" is deprecated
func(None, x=20)

# NOTE: **kw is accepted but also you could put down more than one 
# parameter if needed...
@deprecated_params(['foo'], {"foo":"foo was removed in ... don't use it"}, display_kw=False)
class MyClass:
    def __init__(self, spam:object, **kw):
        self.spam = spam
        self.foo = kw.get("foo", None)

# DeprecationWarning: foo was removed in ... don't use it
mc = MyClass("spam", foo="X")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deprecated_params-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deprecated_params-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file deprecated_params-0.1.0.tar.gz.

File metadata

  • Download URL: deprecated_params-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for deprecated_params-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3003814f19ee72d55bf27b4fe817a0013aea990110cbbbb3dab8a28c5b89b865
MD5 1313b34413ee084ffa306494cfad81ab
BLAKE2b-256 3c3e1b3e565a37459385c6b754eba2d58d7cbb7cf4dc8dbe237378ad96f9e12a

See more details on using hashes here.

File details

Details for the file deprecated_params-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for deprecated_params-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d78b14381274caa3ec81474bc69a26319b53f389304f1daede28944a6e0bd8e5
MD5 5c2a733e6124415fb63dc6c4f82dca25
BLAKE2b-256 40b3771b962857013e8f5a4c253cc49bad52eeedbac6f75d2303ffca87bddaab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page