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)

Nmap script to guess* a GitLab version.

gitlab-version-nse Nmap script to guess* a GitLab version. Usage https://github.com/righel/gitlab-version-nse cd gitlab-version-nse nmap target --s

Luciano Righetti 120 Dec 05, 2022
An awesome tool to save articles from RSS feed to Pocket automatically.

RSS2Pocket An awesome tool to save articles from RSS feed to Pocket automatically. About the Project I used to use IFTTT to save articles from RSS fee

Hank Liao 10 Nov 12, 2022
A library from RCTI+ to handle RabbitMQ tasks (connect, send, receive, etc) in Python.

Introduction A library from RCTI+ to handle RabbitMQ tasks (connect, send, receive, etc) in Python. Requirements Python =3.7.3 Pika ==1.2.0 Aio-pika

Dali Kewara 1 Feb 05, 2022
Pampy: The Pattern Matching for Python you always dreamed of.

Pampy: Pattern Matching for Python Pampy is pretty small (150 lines), reasonably fast, and often makes your code more readable and hence easier to rea

Claudio Santini 3.5k Jan 06, 2023
Python utilities for writing cross-version compatible libraries

Python utilities for writing cross-version compatible libraries

Tyler M. Kontra 85 Jun 29, 2022
password generator

Password generator technologies used What is? It is Password generator How to Download? Download on releases Clone repo git clone https://github.com/m

1 Dec 16, 2021
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
Display your calendar on the wallpaper.

wallCal Have your calendar appear as the wallpaper. disclaimer Use at your own risk. Don't blame me if you miss a meeting :-) Some parts of the script

7 Jun 14, 2022
A work in progress box containing various Python utilities

python-wipbox A set of modern Python libraries under development to simplify the execution of reusable routines by different projects. Table of Conten

Deepnox 2 Jan 20, 2022
aws ec2.py companion script to generate sshconfigs with auto bastion host discovery

ec2-bastion-sshconfig This script will interate over instances found by ec2.py and if those instances are not publically accessible it will search the

Steve Melo 1 Sep 11, 2022
Basic loader is a small tool that will help you generating Cloudflare cookies

Basic Loader Cloudflare cookies loader This tool may help some people getting valide cloudflare cookies Installation 🔌 : pip install -r requirements.

IHateTomLrge 8 Mar 30, 2022
This repository contains some utilities for playing with PKINIT and certificates.

PKINIT tools This repository contains some utilities for playing with PKINIT and certificates. The tools are built on minikerberos and impacket. Accom

Dirk-jan 395 Dec 27, 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
jfc is an utility to make reviewing ArXiv papers for your Journal Club easier.

jfc is an utility to make reviewing ArXiv papers for your Journal Club easier.

Miguel M. 3 Dec 20, 2021
Just some scripts to export vector tiles to geojson.

Vector tiles to GeoJSON Nowadays modern web maps are usually based on vector tiles. The great thing about vector tiles is, that they are not just imag

Lilith Wittmann 77 Jul 26, 2022
Adding two matrix from scratch using python.

Adding-two-matrix-from-scratch-using-python. Here, I have take two matrix from user and add it without using any library. I made this program from scr

Sachin Vinayak Dabhade 4 Sep 24, 2021
Python script to launch burp scans automatically

SimpleAutoBurp Python script that takes a config.json file as config and uses Burp Suite Pro to scan a list of websites.

Adan Álvarez 26 Jul 18, 2022
Python HTTP Agent Parser

Features Fast Detects OS and Browser. Does not aim to be a full featured agent parser Will not turn into django-httpagentparser ;) Usage import ht

Shekhar 213 Dec 06, 2022
A morse code encoder and decoder utility.

morsedecode A morse code encoder and decoder utility. Installation Install it via pip: pip install morsedecode Alternatively, you can use pipx to run

Tushar Sadhwani 2 Dec 25, 2021
Local backup made easy, with Python and shutil

KTBackup BETA Local backup made easy, with Python and shutil Features One-command backup and restore Minimalistic (only using stdlib) Convenient direc

kelptaken 1 Dec 27, 2021