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 License: Appache-2.0 NO AI

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 approach to an argument you wish to deprecate. Most of the times these arguments will most likely be one of 3 cases.

  • misspellings
  • better functionality that replaces old arguments with better ones.
  • removed parameters but you want to warn developers to move without being aggressive about it.
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")

Why I wrote Deprecated Params

I got tired of throwing random warnings in my code and wanted something cleaner that didn't interfere with a function's actual code and didn't blind anybody trying to go through it. Contributors and Reviewers should be able to utilize a library that saves them from these problems while improving the readability of a function. After figuring out that the functionality I was looking for didn't exist I took the opportunity to implement it.

Goals With this library

  • Keep up to date and maintained until sometime around 2040 or when something new obsoletes the need for it
    • Example: If the standard python library were to introduce it's own adaptation of deprecated-params
  • Remain tiny or as a single module with no additional dependencies unless needed for backwards compatible versions of python example: typing-extensions.
  • This Library will Never Be Vibe Coded. It is simplistic enough for anybody with a decent understanding of python to understand the underlying mechanics behind how the classes and functions work. Under this philosophy, AI will never be relied on and will continue to remain human-made & maintained for the rest of time.

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.9.0.tar.gz (10.3 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.9.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deprecated_params-0.9.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for deprecated_params-0.9.0.tar.gz
Algorithm Hash digest
SHA256 eefbfe6065bc64cbd309e8c640dc6c732c47d0d6c78f46df5d506d4ed6592baf
MD5 993e1ab8df7c6e9bce1aec6d990a2819
BLAKE2b-256 af9b70ca5faeaedfd11e76f35f24c28b60049a0229c04c640808399338356eca

See more details on using hashes here.

Provenance

The following attestation bundles were made for deprecated_params-0.9.0.tar.gz:

Publisher: python-publish.yml on Vizonex/deprecated-params

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for deprecated_params-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9d057c90af519b5ffa99de79406d994aa4d55925f3c59b4ef776ae41039b171
MD5 2cce446de529f4d95f761aa03e350cc8
BLAKE2b-256 c5ac9182b464ed4aab003ab1ace0baff952cb81ef1210dc2fcba04d48fb06188

See more details on using hashes here.

Provenance

The following attestation bundles were made for deprecated_params-0.9.0-py3-none-any.whl:

Publisher: python-publish.yml on Vizonex/deprecated-params

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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