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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6311c113263565e1e5cde4791952c753a118db14eee198e4bfe53d3e8e0c0d5c
|
|
| MD5 |
b5c4f14ff37dec59cd0898203bfa7907
|
|
| BLAKE2b-256 |
e0071fff11e2deef28d558075cfea7950eae92437b688be5e73a46e209b34bcb
|
File details
Details for the file deprecated_params-0.1.2-py3-none-any.whl.
File metadata
- Download URL: deprecated_params-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbac3c627fb037ad79a72688d6861aec52c08d4aa4ae3f21078f5c27eb08550b
|
|
| MD5 |
238c494ffaae51131b80324508247347
|
|
| BLAKE2b-256 |
8799d6bad624b949e214619c604f3791318a41fa0fdafbfe9f7c4927f34a8fc4
|