Skip to main content

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

Project description

Deprecated Params

PyPI version PyPI - Downloads License: MIT

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.3.tar.gz (5.6 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.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deprecated_params-0.1.3.tar.gz
  • Upload date:
  • Size: 5.6 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.3.tar.gz
Algorithm Hash digest
SHA256 985b78b2fc7b0467367e5553071d44ffbd097124f4d1e66897bfe314e02198a2
MD5 b8a774090476734b1acd46aa8cd83f15
BLAKE2b-256 c12b1b58745abc678a40e9a3c03613d32dafbfa4ec7e9a135d5beeb5bca88a8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for deprecated_params-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7d76f225211c6597f1e6a745324ef035bfb0e3e0521aaa9f05e44165fa781161
MD5 dcef9bb96a7d4cffe510274a10f2d66a
BLAKE2b-256 5c9f9c3cf7e8d68ada65a8cdc4c4157ff8cc6cfe1009c41cdc8fa0755f5c52f4

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