Python @deprecat decorator to deprecate old python classes, functions or methods.

Overview

deprecat Decorator

Python @deprecat decorator to deprecate old python classes, functions or methods.

Installation

pip install deprecat

Usage

To use this, decorate your deprecated function with @deprecat decorator:

from deprecat import deprecat


@deprecat
def some_old_function(x, y):
    return x + y

You can also decorate a class or a method:

from deprecated import deprecat


class SomeClass(object):
    @deprecat
    def some_old_method(self, x, y):
        return x + y


@deprecat
class SomeOldClass(object):
    pass

You can give a "reason" message to help the developer to choose another function/class:

from deprecat import deprecat


@deprecat(reason="use another function")
def some_old_function(x, y):
    return x + y

Authors

The authors of this library are: Marcos CARDOSO, and Laurent LAPORTE. The original code was made in this StackOverflow post by Leandro REGUEIRO, Patrizio BERTONI, and Eric WIESER.

Modified and now maintained by: Meenal Jhajharia

Comments
  • Decorator breaks when there's no

    Decorator breaks when there's no "Parameters" section in the docstring

    On a method that doesn't have a docstring at all, or is missing the expected section, the search result is None:

    search = re.search("Parameters[\s]*\n[\s]*----------", docstring)
    params_string = docstring[search.start():search.end()]
    

    Traceback

    ...\deprecat\classic.py:217: in deprecat
        return wrapper_function(wrapped)
    ...\wrapt\decorators.py:417: in _wrapper
        return _build(target_wrapped, target_wrapper, _enabled, adapter)
    ...\wrapt\decorators.py:207: in _build
        adapter = adapter(wrapped)
    ...\deprecat\sphinx.py:145: in __call__
        params_string = docstring[search.start():search.end()]
    E   AttributeError: 'NoneType' object has no attribute 'start'
    
    opened by michaelosthege 2
  • Update tests

    Update tests

    All the tests are unmodified and taken as it is from github:tantale/deprecated, we need to change them to suit the new features such as deprecated_args

    opened by mjhajharia 2
  • Autogenerate the docstring examples

    Autogenerate the docstring examples

    There is a https://deprecat.readthedocs.io/en/latest/source/usage.html#docstring section which is hardcoded in rST instead of showing the actual output.

    I would try to create a showcase module inside the library that is not used by it nor exposed when imported but has one example of each deprecation type, class, function, method, kwarg... and then create a showcase api docs. I think this will serve also as a rudimentary test that the output looks as desired when doing changes in a way that automated tests can't

    opened by OriolAbril 1
  • try quick fix

    try quick fix

    I don't really understand what the code is doing, but there seem to be some missing indent substitutions. I tried changing only this in case it helps. From https://github.com/pymc-devs/pymc/pull/5226 there is clearly an issue of missing indents.

    opened by OriolAbril 1
  • Decorator breaks when the deprecated arg is not in the docstring

    Decorator breaks when the deprecated arg is not in the docstring

    Very similar to #5 this line assumes that the deprecated kwarg is in the docstring:

    description_start = re.search(f"\n{indent}{arg}\s*:", params_section).end()
    

    ...but again the search returns None if it's not found.

    opened by michaelosthege 1
Releases(v2.1.1)
  • v2.1.1(Jan 27, 2022)

    This release adds tests for the new features that deprecat adds on top of the original library that was forked (tantale/deprecated), namely:

    • tests for deprecated arguments warnings in functions, classes, static methods
    • tests for sphinx docstrings for deprecated arguments
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Dec 1, 2021)

  • v2.0.0(Nov 5, 2021)

Owner
null
Allows you to canibalize methods from classes effectively implementing trait-oriented programming

About This package enables code reuse in non-inheritance way from existing classes, effectively implementing traits-oriented programming pattern. Stor

null 1 Dec 13, 2021
A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

PyBash 11 May 22, 2022
pydsinternals - A Python native library containing necessary classes, functions and structures to interact with Windows Active Directory.

pydsinternals - Directory Services Internals Library A Python native library containing necessary classes, functions and structures to interact with W

Podalirius 36 Dec 14, 2022
Cleaning-utils - a collection of small Python functions and classes which make cleaning pipelines shorter and easier

cleaning-utils [] [] [] cleaning-utils is a collection of small Python functions

null 4 Aug 31, 2022
API Rate Limit Decorator

ratelimit APIs are a very common way to interact with web services. As the need to consume data grows, so does the number of API calls necessary to re

Tomas Basham 575 Jan 5, 2023
Python Classes Without Boilerplate

attrs is the Python package that will bring back the joy of writing classes by relieving you from the drudgery of implementing object protocols (aka d

The attrs Cabal 4.6k Jan 6, 2023
A simple python script to generate an iCalendar file for the university classes.

iCal Generator This is a simple python script to generate an iCalendar file for the university classes. Installation Clone the repository git clone ht

Foad Rashidi 2 Sep 1, 2022
Factoral Methods using two different method

Factoral-Methods-using-two-different-method Here, I am finding the factorial of a number by using two different method. The first method is by using f

Sachin Vinayak Dabhade 4 Sep 24, 2021
Helpful functions for use alongside the rich Python library.

?? Rich Tools A python package with helpful functions for use alongside with the rich python library. ???? The current features are: Convert a Pandas

Avi Perl 14 Oct 14, 2022
A simple and easy to use collection of random python functions.

A simple and easy to use collection of random python functions.

Diwan Mohamed Faheer 1 Nov 17, 2021
A collection of utility functions to prototype geometry processing research in python

gpytoolbox This repo is a work in progress and contains general utility functions I have needed to code while trying to work on geometry process resea

Silvia Sellán 73 Jan 6, 2023
Python Libraries with functions and constants related to electrical engineering.

ElectricPy Electrical-Engineering-for-Python Python Libraries with functions and constants related to electrical engineering. The functions and consta

Joe Stanley 39 Dec 23, 2022
This script allows you to retrieve all functions / variables names of a Python code, and the variables values.

Memory Extractor This script allows you to retrieve all functions / variables names of a Python code, and the variables values. How to use it ? The si

Venax 2 Dec 26, 2021
A simple example for calling C++ functions in Python by `ctypes`.

ctypes-example A simple example for calling C++ functions in Python by ctypes. Features call C++ function int bar(int* value, char* msg) with argumene

Yusu Pan 3 Nov 23, 2022
Make your functions return something meaningful, typed, and safe!

Make your functions return something meaningful, typed, and safe! Features Brings functional programming to Python land Provides a bunch of primitives

dry-python 2.6k Jan 9, 2023
We provide useful util functions. When adding a util function, please add a description of the util function.

Utils Collection Motivation When we implement codes, we often search for util functions that are already implemented. Here, we are going to share util

null 6 Sep 9, 2021
Keval allows you to call arbitrary Windows kernel-mode functions from user mode, even (and primarily) on another machine.

Keval Keval allows you to call arbitrary Windows kernel-mode functions from user mode, even (and primarily) on another machine. The user mode portion

null 42 Dec 17, 2022
Conveniently measures the time of your loops, contexts and functions.

Conveniently measures the time of your loops, contexts and functions.

Maciej J Mikulski 79 Nov 15, 2022
Run functions in parallel easily, with their results typed correctly!

typesafe_parmap pip install pip install typesafe-parmap Run functions in parallel safely with typesafe parmap! GitHub: https://github.com/thejaminato

James Chua 3 Nov 6, 2021