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)

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

1 Dec 13, 2021
Script to decrypt / import chromium (edge/chrome) cookies

Cloonie Script to decrypt / import chromium (edge/chrome) cookies. Requirements Install the python dependencies via pip: pip install -r requirements.t

Lorenzo Bernardi 5 Sep 13, 2022
Python program for Linux users to change any url to any domain name they want.

URLMask Python program for Linux users to change a URL to ANY domain. A program than can take any url and mask it to any domain name you like. E.g. ne

2 Jun 20, 2022
Dynamic key remapper for Wayland Window System, especially for Sway

wayremap Dynamic keyboard remapper for Wayland. It works on both X Window Manager and Wayland, but focused on Wayland as it intercepts evdev input and

Kay Gosho 50 Nov 29, 2022
RapidFuzz is a fast string matching library for Python and C++

RapidFuzz is a fast string matching library for Python and C++, which is using the string similarity calculations from FuzzyWuzzy

Max Bachmann 1.7k Jan 04, 2023
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
Macro recording and metaprogramming in Python

macro-kit is a package for efficient macro recording and metaprogramming in Python using abstract syntax tree (AST).

8 Aug 31, 2022
Script for generating Hearthstone card spoilers & checklists

This is a script for generating text spoilers and set checklists for Hearthstone. Installation & Running Python 3.6 or higher is required. Copy/clone

John T. Wodder II 1 Oct 11, 2022
✨ Une calculatrice totalement faite en Python par moi, et en français.

Calculatrice ❗ Une calculatrice totalement faite en Python par moi, et en français. 🔮 Voici une calculatrice qui vous permet de faire vos additions,

MrGabin 3 Jun 06, 2021
Python @deprecat decorator to deprecate old python classes, functions or methods.

deprecat Decorator Python @deprecat decorator to deprecate old python classes, functions or methods. Installation pip install deprecat Usage To use th

12 Dec 12, 2022
ecowater-softner is a Python library for collecting information from Ecowater water softeners.

Ecowater Softner ecowater-softner is a Python library for collecting information from Ecowater water softeners. Installation Use the package manager p

6 Dec 08, 2022
Quickly edit your slack posts.

Lightning Edit Quickly edit your Slack posts. Heavily inspired by @KhushrajRathod's LightningDelete. Usage: Note: Before anything, be sure to head ove

14 Nov 19, 2021
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
Let's renew the puzzle collection. We'll produce a collection of new puzzles out of the lichess game database.

Let's renew the puzzle collection. We'll produce a collection of new puzzles out of the lichess game database.

Thibault Duplessis 96 Jan 03, 2023
A python program to find binary, octal and hexadecimal of a decimal.

decimal-converter This little python program can convert a decimal in to, Binary Octal Hexadecimal Needed Python 3 or later or a online python compile

Chandula Janith 0 Nov 27, 2021
Use generator for range function

Use the generator for the range function! installation method: pip install yrange How to use: First import yrange in your application. You can then wo

1 Oct 28, 2021
A collection of custom scripts for working with Quake assets.

Custom Quake Tools A collection of custom scripts for working with Quake assets. Features Script to list all BSP files in a Quake mod

Jason Brownlee 3 Jul 05, 2022
Various importers for cointracker

cointracker_importers Various importers for cointracker To convert nexo .csv format to cointracker .csv format: Download nexo csv file. run python Nex

Stefanos Anastasiou 9 Oct 24, 2022
kawadi is a versatile tool that used as a form of weapon and is used to cut, shape and split wood.

kawadi kawadi (કવાડિ in Gujarati) (Axe in English) is a versatile tool that used as a form of weapon and is used to cut, shape and split wood. kawadi

Jay Vala 2 Jan 10, 2022
.bvh to .mcfunction file converter.

bvh-to-mcf .bvh file to .mcfunction converter

Hanmin Kim 28 Nov 21, 2022