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)

Library for processing molecules and reactions in python way

Chython [ˈkʌɪθ(ə)n] Library for processing molecules and reactions in python way. Features: Read/write/convert formats: MDL .RDF (.RXN) and .SDF (.MOL

16 Dec 01, 2022
Create password - Generate Random Password with Passphrase

Generate Random Password with Passphrase This is a python code to generate stron

1 Jan 18, 2022
Modest utility collection for development with AIOHTTP framework.

aiohttp-things Modest utility collection for development with AIOHTTP framework. Documentation https://aiohttp-things.readthedocs.io Installation Inst

Ruslan Ilyasovich Gilfanov 0 Dec 11, 2022
A Randomizer Oracle

Tezos Randomizer Tezod Randomizer "Oracle". It's a smart contract that you can call to get a random number between X and Y (for now). It uses entropy

Asbjorn Enge 19 Sep 13, 2022
Easy compression and extraction for any compression or archival format.

Tzar: Tar, Zip, Anything Really Easy compression and extraction for any compression or archival format. Usage/Examples tzar compress large-dir compres

DanielVZ 37 Nov 02, 2022
The git for the Python Story Utility Package library.

SUP The git for the Python Story Utility Package library. Installation: Install SUP by simply running pip install psup in your terminal. Check out our

Enoki 6 Nov 27, 2022
Package that allows for validate and sanitize of string values.

py.validator A library of string validators and sanitizers Insipired by validator.js Strings only This library validates and sanitizes strings only. P

Sanel Hadzini 22 Nov 08, 2022
A quick username checker to see if a username is available on a list of assorted websites.

A quick username checker to see if a username is available on a list of assorted websites.

Maddie 4 Jan 04, 2022
Dice Rolling Simulator using Python-random

Dice Rolling Simulator As the name of the program suggests, we will be imitating a rolling dice. This is one of the interesting python projects and wi

PyLaboratory 1 Feb 02, 2022
Format Norminette Output!

Format Norminette Output!

7 Apr 19, 2022
Toolkit for collecting and applying templates of prompting instances

PromptSource Toolkit for collecting and applying templates of prompting instances. WIP Setup Download the repo Navigate to root directory of the repo

BigScience Workshop 1k Jan 05, 2023
Simple profile athena generator for Fortnite Private Servers.

Profile-Athena-Generator A simple profile athena generator for Fortnite Private Servers. This profile athena generrator features: Item variants Get al

Fevers 10 Aug 27, 2022
Abstraction of a Unit, includes convertions and basic operations.

Units Abstraction of a Unit, includes convertions and basic operations. ------ EXAMPLE : Free Fall (No air resistance) ------- from units_test import

1 Dec 23, 2021
Raganarok X: Next Generation Data Dump

Raganarok X Data Dump Raganarok X: Next Generation Data Dump More interesting Files File Name Contains en_langs All the variables you need in English

14 Jul 15, 2022
Color box that provides various colors‘ rgb decimal code.

colorbox Color box that provides various colors‘ rgb decimal code

1 Dec 07, 2021
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
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 06, 2021
Python library to decorate and beautify strings

outputformat Python library to decorate and beautify your standard output 💖 Ins

Felipe Delestro Matos 259 Dec 13, 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
Pyfunctools is a module that provides functions, methods and classes that help in the creation of projects in python

Pyfunctools Pyfunctools is a module that provides functions, methods and classes that help in the creation of projects in python, bringing functional

Natanael dos Santos Feitosa 5 Dec 22, 2022