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)

Manage your exceptions in Python like a PRO

A linter to manage all your python exceptions and try/except blocks (limited only for those who like dinosaurs).

Guilherme Latrova 353 Dec 31, 2022
A collection of tools for biomedical research assay analysis in Python.

waltlabtools A collection of tools for biomedical research assay analysis in Python. Key Features Analysis for assays such as digital ELISA, including

Tyler Dougan 1 Apr 18, 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

4 Aug 31, 2022
Utility to extract Fantasy Grounds Unity Line-of-sight and lighting files from a Univeral VTT file exported from Dungeondraft

uvtt2fgu Utility to extract Fantasy Grounds Unity Line-of-sight and lighting files from a Univeral VTT file exported from Dungeondraft This program wo

Andre Kostur 29 Dec 05, 2022
Check username

Checker-Oukee Check username It checks the available usernames and creates a new account for them Doesn't need proxies Create a file with usernames an

4 Jun 05, 2022
Simple RGB to HEX game made in python

Simple RGB to HEX game made in python

5 Aug 26, 2022
Convert any-bit number to decimal number and vise versa.

2deci Convert any-bit number to decimal number and vise versa. --bit n to set bit to n --exp xxx to set expression to xxx --r to run reversely (from d

3 Sep 15, 2021
A simple Python app that generates semi-random chord progressions.

chords-generator A simple Python app that generates semi-random chord progressions.

53 Sep 07, 2022
A python module for extract domains

A python module for extract domains

Fayas Noushad 4 Aug 10, 2022
Two fast AUC calculation implementations for python

fastauc Two fast AUC calculation implementations for python: python-based is approximately 5X faster than the default sklearn.metrics.roc_auc_score()

Vsevolod Kompantsev 26 Dec 11, 2022
Implementing C++ Semantics in Python

Implementing C++ Semantics in Python

Tamir Bahar 7 May 18, 2022
Michael Vinyard's utilities

Install vintools To download this package from pypi: pip install vintools Install the development package To download and install the developmen

Michael Vinyard 2 May 22, 2022
Utility to add/remove licenses to/from source files

Utility to add/remove licenses to/from source files. Supports processing any combination of globs, files, and directories (recurse). Pruning options allow skipping non-licensing files.

Eduardo Ponce Mojica 2 Jan 29, 2022
A Python package for floating-point binary fractions. Do math in base 2!

An implementation of a floating-point binary fractions class and module in Python. Work with binary fractions and binary floats with ease!

10 Oct 29, 2022
A monitor than send discord webhook when a specific monitored product has stock in your nearby pickup stores.

Welcome to Apple In-store Monitor This is a monitor that are not fully scaled, and might still have some bugs.

5 Jun 16, 2022
cpp20.py is a Python script to compile C++20 code using modules.

cpp20.py is a Python script to compile C++20 code using modules. It browses the source files to determine their dependencies. Then, it compiles then in order using the correct flags.

Julien VERNAY 6 Aug 26, 2022
A python module to manipulate XCode projects

This module can read, modify, and write a .pbxproj file from an Xcode 4+ projects. The file is usually called project.pbxproj and can be found inside the .xcodeproj bundle. Because some task cannot b

Ignacio Calderon 1.1k Jan 02, 2023
a demo show how to dump lldb info to ida.

用一个demo来聊聊动态trace 这个仓库能做什么? 帮助理解动态trace的思想。仓库内的demo,可操作,可实践。 动态trace核心思想: 动态记录一个函数内每一条指令的执行中产生的信息,并导入IDA,用来弥补IDA等静态分析工具的不足。 反编译看一下 先clone仓库,把hellolldb

25 Nov 28, 2022
A Container for the Dependency Injection in Python.

Python Dependency Injection library aiodi is a Container for the Dependency Injection in Python. Installation Use the package manager pip to install a

Denis NA 3 Nov 25, 2022
ColorController is a Pythonic interface for managing colors by english-language name and various color values.

ColorController.py Table of Contents Encode color data in various formats. 1.1: Create a ColorController object using a familiar, english-language col

Tal Zaken 2 Feb 12, 2022