Python decorator for `TODO`s

Overview

todo-or-die [Python edition]

Don't let your TODOs rot in your python projects anymore !

Inspired by :

Examples

Once installed in your project, you can use it in any part of your code:

1000) # it also accepts a callable as a first argument def myfunc(): return 42 result = todo_or_die(myfunc, "Fix this in 6 months", by=datetime.date(2021, 6, 31)) result == 42 # True # or simply any value will be passed back result = todo_or_die(42, "Fix this in 6 months", by=datetime.date(2021, 6, 31)) result == 42 # True from myapp import __version__ # Finally, you can use it as a function decorator @TodoOrDie("This function should be removed in the next version", when=__version__ > 2000) def myfunc(some = "arg"): pass ">
from todo_or_die import todo_or_die, TodoOrDie

# raise an OverdueException when we're after a certain date or datetime
todo_or_die("This should be fixed by now.", by = datetime.datetime(2021, 6, 25, 15, 34, 55))

# raise an OverdueException when a given condition is true
todo_or_die("This should fail when we reach 1000 users", when = DB.users.count() > 1000)

# it also accepts a callable as a first argument
def myfunc():
    return 42

result = todo_or_die(myfunc, "Fix this in 6 months", by=datetime.date(2021, 6, 31))
result == 42 # True

# or simply any value will be passed back
result = todo_or_die(42, "Fix this in 6 months", by=datetime.date(2021, 6, 31))
result == 42 # True

from myapp import __version__

# Finally, you can use it as a function decorator
@TodoOrDie("This function should be removed in the next version", when=__version__ > 2000)
def myfunc(some = "arg"):
    pass

Keep your projects clean

To understand why you would ever call a function to write a comment, read on.

If you have some code you know you'll need to change later, don't just leave a comment for later that you'll never read, ever again.

For all the following cases, forgetting a TODO is NOT GOOD:

  • remove some code when the dependency support expires,
  • remove a feature flag,
  • update some code related to another project,
  • update a dependency when another refactoring is done,
  • ...

This can lead to nasty issues so make your TODOs speak up when they need to with this module ;)

You can now replace your simple comment with this function that will raise and error when the time or the condition are met and remind you to do something about it.

Caution

This can cause some production apps to break ! This code is named todo_or_die, not todo_and_kittens so be careful.

Pull-Requests are welcome to make this more production-ready !

Note this module has no warranty, see the LICENSE !

You might also like...
this is a basic python project that I made using python

this is a basic python project that I made using python. This project is only for practice because my python skills are still newbie.

Analisador de strings feito em Python // String parser made in Python

Este é um analisador feito em Python, neste programa, estou estudando funções e a sua junção com "if's" e dados colocados pelo usuário. Neste código,

Python with braces. Because Python is awesome, but whitespace is awful.

Bython Python with braces. Because Python is awesome, but whitespace is awful. Bython is a Python preprosessor which translates curly brackets into in

PSP (Python Starter Package) is meant for those who want to start coding in python but are new to the coding scene.

Python Starter Package PSP (Python Starter Package) is meant for those who want to start coding in python, but are new to the coding scene. We include

Py-Parser est un parser de code python en python encore en plien dévlopement.

PY - PARSER Py-Parser est un parser de code python en python encore en plien dévlopement. Une fois achevé, il servira a de nombreux projets comme glad

Simple, high-school-leveled sequence library written in Python / 간단한 고등학교 수준 수열 라이브러리 (Python)
A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz

A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz has some issues building with python 3.10

A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning  Essence.
A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

Run python scripts and pass data between multiple python and node processes using this npm module

Run python scripts and pass data between multiple python and node processes using this npm module. process-communication has a event based architecture for interacting with python data and errors inside nodejs.

Owner
Klemen Sever
Dev from 42.fr, Osteopath, Founder of https://www.osteopathes.pro , https://www.kwelo.com & more.
Klemen Sever
decorator

Decorators for Humans The goal of the decorator module is to make it easy to define signature-preserving function decorators and decorator factories.

Michele Simionato 734 Dec 30, 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 574 Dec 26, 2022
This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator

Late-Bound Arguments This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator. Usage Mention the names of the argumen

Shakya Majumdar 0 Feb 6, 2022
A python tool that creates issues in your repos based on TODO comments in your code

Krypto A neat little sidekick python script to create issues on your repo based on comments left in the code on your behalf Convert todo comments in y

Alex Antoniou 4 Oct 26, 2021
A TODO-list tool written in Python

PyTD A TODO-list tool written in Python. Its goal is to provide a stable posibility to get a good view over all your TODOs motivate you to actually fi

null 1 Feb 12, 2022
ToDo - A simple bot to keep track of things you need to do

ToDo A simple bot to keep track of things you need to do. Installation You will

null 3 Sep 18, 2022
[x]it! support for working with todo and check list files in Sublime Text

[x]it! for Sublime Text This Sublime Package provides syntax-highlighting, shortcuts, and auto-completions for [x]it! files. Features Syntax highlight

Jan Heuermann 18 Sep 19, 2022
Todos os exercícios do Curso de Python, do canal Curso em Vídeo, resolvidos em Python, Javascript, Java, C++, C# e mais...

Exercícios - CeV Oferecido por Linguagens utilizadas atualmente O que vai encontrar aqui? ?? Esse repositório é dedicado a armazenar todos os enunciad

Coding in Community 43 Nov 10, 2022
PyDy, short for Python Dynamics, is a tool kit written in the Python

PyDy, short for Python Dynamics, is a tool kit written in the Python programming language that utilizes an array of scientific programs to enable the study of multibody dynamics. The goal is to have a modular framework and eventually a physics abstraction layer which utilizes a variety of backends that can provide the user with their desired workflow

PyDy 307 Jan 1, 2023
A Python script made for the Python Discord Pixels event.

Python Discord Pixels A Python script made for the Python Discord Pixels event. Usage Create an image.png RGBA image with your pattern. Transparent pi

Stanisław Jelnicki 4 Mar 23, 2022