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.1.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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deprecated_params-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 82bf0b2739d1d548ff4f8e4cb0f5aa5c85a075f6727034b69ec556bdc494417d
MD5 2042dbf84c8f6041a900b27bb1629c85
BLAKE2b-256 c9cd4fe592954d2133bbc1102c5868985bae77d931fe4438223f5cc22d872dd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for deprecated_params-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b2c3d472529789e4286ade710e0db815d320e558e798626e148e7127ced01b1
MD5 e58289d9080619e3a604e26cd41511cf
BLAKE2b-256 80a41f82152dc3db975609fa1371e4487c08d7c651a77cc78674d60406414307

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