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 !

Owner
Klemen Sever
Dev from 42.fr, Osteopath, Founder of https://www.osteopathes.pro , https://www.kwelo.com & more.
Klemen Sever
Materials and information for my PyCascades 2021 Presentation

Materials and information for PyCascades 2021 Presentation: Sparking Creativity in LED Art with CircuitPython

GeekMomProjects 19 May 04, 2022
Table (Finnish Taulukko) glued together to transform into hands-free living.

taulukko Table (Finnish Taulukko) glued together to transform into hands-free living. Installation Preferred way to install is as usual (for testing o

Stefan Hagen 2 Dec 14, 2022
Nimbus - Open Source Cloud Computing Software - 100% Apache2 licensed

⚠️ The Nimbus infrastructure project is no longer under development. ⚠️ For more information, please read the news announcement. If you are interested

Nimbus 194 Jun 30, 2022
TinyBar - Tiny MacOS menu bar utility to track price dynamics for assets on TinyMan.org

📃 About A simple MacOS menu bar app to display current coins from most popular Liquidity Pools on TinyMan.org

Al 8 Dec 23, 2022
Repository to store sample python programs for python learning

py Repository to store sample Python programs. This repository is meant for beginners to assist them in their learning of Python. The repository cover

codebasics 5.8k Dec 30, 2022
A tool to build reproducible wheels for you Python project or for all of your dependencies

asaman: Amra Saman (আমরা সমান) This is a tool to build reproducible wheels for your Python project or for all of your dependencies. What this means is

Kushal Das 14 Aug 05, 2022
All solutions for the 2021 Advent of Code event.

Advent of Code 2021 Solutions All solutions for the 2021 Advent of Code event. Setup Create a file called .session. Go to adventofcode.com and copy th

Bruce Berrios 6 Dec 26, 2021
A repository containing an introduction to Panel made to be support videos and talks.

👍 Awesome Panel - Introduction to Panel THIS REPO IS WORK IN PROGRESS. PRE-ALPHA Panel is a very powerful framework for exploratory data analysis and

Marc Skov Madsen 51 Nov 17, 2022
Automator anble you to create automations on your system

WELCOME TO AUTOMATOR BETA This programm is able to create automations on your system. This programm is only an experimantal release; infact it works v

Davide 1 Jan 12, 2022
Final project for ENGG 5402 Advanced Robotics in CUHK

Final project Final project Update Foundations Ubuntu virtual machine Ubuntu How to use Github to keep tracking the change of code version? Docker Set

Junjia Liu 8 Aug 01, 2022
EFB Docker image with efb-telegram-master and efb-wechat-slave

efb-wechat-docker EFB Docker image with efb-telegram-master and efb-wechat-slave Features Container run by non-root user. Support add environment vari

Haukeng 1 Nov 10, 2022
python scripts to perform coin die clustering (performed on Riedones3D).

python scripts to perform coin die clustering (performed on Riedones3D).

Sofiane 2 Apr 29, 2022
A simple package for interacting with the 9kw.eu anti-captcha service.

Welcome to captcha9kw’s documentation! captcha9kw is a smallish Python package for making use of the 9kw.eu services, including solving of interactive

2 Feb 26, 2022
Arknights gacha simulation written in Python

Welcome to arknights-gacha repository This is my shameless attempt of simulating Arknights gacha. Current supported banner types (with potential bugs)

Swyrin 3 May 07, 2022
Blender addon for executing the operator in response to the received OSC message.

I/F Joiner 受信したOSCメッセージに応じてオペレータ(bpy.ops)を実行するアドオンです. OSC通信に対応したコントローラやアプリをインストールしたスマートフォンを使用してBlenderを操作することが可能になります. 同時開発しているAndroidコントローラ化アプリMocopa

simasimataiyo 6 Oct 02, 2022
Python Example Project Structure

Python Example Project Structure Example of statuses that can be in readme: Visit my docs for the full documentation, examples and guides. With this p

1 Oct 31, 2021
Banking management project using Tkinter GUI in python.

Bank-Management Banking management project using Tkinter GUI in python. Packages required Tkinter - Tkinter is the standard GUI library for Python. sq

Anjali Kumawat 7 Jul 03, 2022
Replit theme sync; Github theme sync but in Replit.

This is a Replit theme sync, basically meaning that it keeps track of the current time (which may need to be edited later on), and if the time passes morning, afternoon, etc, the theme switches. The

Glitch 8 Jun 25, 2022
GDIT: Geometry Dash Info Tool

GDIT: Geometry Dash Info Tool This is the first large script that allows you to quickly get information from the Geometry Dash server

dezz0xY 2 Jan 09, 2022
This project recreates the R-based RCy3 Cytoscape Automation library as a Python package.

Python library for calling Cytoscape Automation via CyREST

Cytoscape Consortium 40 Dec 22, 2022