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

Uploaded Python 3

File details

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

File metadata

  • Download URL: deprecated_params-0.1.2.tar.gz
  • Upload date:
  • Size: 5.5 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.2.tar.gz
Algorithm Hash digest
SHA256 6311c113263565e1e5cde4791952c753a118db14eee198e4bfe53d3e8e0c0d5c
MD5 b5c4f14ff37dec59cd0898203bfa7907
BLAKE2b-256 e0071fff11e2deef28d558075cfea7950eae92437b688be5e73a46e209b34bcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for deprecated_params-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cbac3c627fb037ad79a72688d6861aec52c08d4aa4ae3f21078f5c27eb08550b
MD5 238c494ffaae51131b80324508247347
BLAKE2b-256 8799d6bad624b949e214619c604f3791318a41fa0fdafbfe9f7c4927f34a8fc4

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