Python deprecation factory ensuring useful warnings and docstrings for different deprecations.
Project description
Deprecation Factory
Python3 deprecation factory. Automatically write boilerplate code for many kinds of deperecations through python decorators.
- Free software: BSD license
- Documentation
Motivations
Breaking things is important! Breaking other's things is just mean!
The goal of deprecations is to warn other library writers that their code is about to break so you can keep making agressive changes to your own.
Often when you want to deprecate a feature, you end up following a procedure similar to
- Make the useful modification to your code.
- Decide on when the old behaviour should be switched over.
- Add warnings INSIDE your function to warn users.
- Change the function signature to something non-sensical to detect the default behaviour.
- Add messages in the documentation (numpydoc compatible)
Finally, when the behaviour is official depreprecated, you need to do all these changes again.
- Remove the warnings.
- Remove the documentation messages.
- Remove the old behaviour.
- Change the function signature back to something useful.
The goal of this library is to allow you to shortcut steps 3-9. You shouldn't have to revisit the deprecation long after you completed implementing your new features
This library modifies function signatures and docstrings to make the current version of the function appear in autocompletions and on the automatically generated documentation.
The library will point the user to their line of code, so that they can make the appropriate modifications.
It is even safe to leave the deprecators in place after the threshold version has been reached. The decorator will behave as a no-op and your library will use the updated version of your code. Deprecations should not have to be blockers for your development.
Installation
While you can depend on this, I strongly recommend you version the files you need in your project as the API is highly likely to change and break your code.
Make sure you keep a BSD notice in your code when you version this.
Current deprecators
- Deprecator for change of default values in
kwargs
. Handleskwargs
passed as positional arguments too! - Transitionning to keyword only arguments.
Future deprecators
- Swapping the order of positional arguments
- Making an old
kwarg
a manditory positionalarg
- Feature requests are welcome!
Development Lead
- Mark Harfouche
Contributors
Could be you!
How to contribute
Ready to contribute? We use the standard github contribution model. scikit-image has a great writeup on how to setup your environment. Adapt it for our environment.
Cookiecutter
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.2.2 (2018.08.12)
- API change. change_default_parameter now takes a dictionary for the old_kwargs so that parameter names don't conflict
0.2.1 (2018.08.12)
- Merge with other numpydocs so that documentation in Sphinx doesn't crash
0.2.0 (2018.08.11)
- Provide a deprecator for changing the number of keyword only arguments.
0.1.1 (2018.08.09)
- Deprecated arguments appear in order for Python 3.5 as well.
0.1.0 (2018.08.09)
- New deprecator for changing the default value of
kwards
. Handles arguments passed as positional argumnets too.
0.0.1 (2018-07-29)
- First release on PyPi
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
Built Distribution
Hashes for deprecation_factory-0.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73b4b81f7f62f708959b33185d29e0ccb353c83e8b8f5d1b72008417b363f7cb |
|
MD5 | ae4fd43dfd28764bf26287278e1ff1d0 |
|
BLAKE2b-256 | 75f29fbf13e1eaf3efa274c7775925606ce6e0f7a36ff37adbdacb54b689849a |
Hashes for deprecation_factory-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90b7239326e4ab6e066c10916dc0fb69a8ba49f07d950a19be9db4b931ee1b0e |
|
MD5 | 250be76267e0e97812bb6ad870ec14e0 |
|
BLAKE2b-256 | 0f0071507687bdb264d65bd717d65fee9432d7411bce3ccd2469a3f9c538ae7c |