Skip to main content

TODO or Die Python

A common technique for developers is to comment TODO or FIXME above a block of code when they need a reminder to fix a bug, make a change, or refactor something. However, most times we see these notes go unattended for vast periods of time, often indefinitely.

This iteration of TODO or Die solves this issue by allowing developers to assign a due date to their TODOs. An error is raised after passing of the specified date, forcing you to handle your fix.

Installation

Put this in your requirements.txt:

todo_or_die_python

or install with pip:

pip install todo_or_die_python

Usage

Import the todo_or_die function:

from todo_or_die import todo_or_die
Param Name Type Required Description
message string Yes The message that you'd otherwise be commenting.
by string or datetime No The due date you want to complete your TODO by. Accepts a string in the formt %Y-%m-%d (i.e. 2021-09-29), or a DateTime object. Leaving this field empty throws an error immediately.

Production Usage

This package will attempt to find environment variables that suggest if the app is being run in a production environment. If one of these env variables is found, then a warning will be displaying instead of an error being raised. The package looks for the following key-value pairs:

  • PRODUCTION=true
  • DJANGO_ENVIRONMENT=production
  • ENVIRONMENT=production
  • FLASK_ENV=production

Error Handling

When a due date is passed, an OverdueError is raised in development. In a production environment, an OverdueWarning is warned.

If called from a function, the due date check will only be executed when that function is run.

If called from top level in a script, or outside of a function inside a class, the due date check will be executed when the file or class is loaded, respectively.

Examples

from todo_or_die import todo_or_die

# Throws an error immediately
todo_or_die("Use random() instead")
def random_number():
    return 7

# Throws an error becuase this date has passed
todo_or_die("Make more secure", "2020-01-01")
def password_generator():
    return "password"

# Won't throw an error until May 31st, 2029
def add_7_to_input(input):
    todo_or_die("Make more secure", "2029-05-31")
    return input

Potential Future Features

  • Can set specific TODOs to warn only
  • Add env variable to skip all TODO due date checks
  • Allow for custom die method calls, catches, and message

Credits

Idea came from searls' Ruby implementation and davidpdrsn's Rust implementation

Metadata

Release files for todo-or-die-python 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for todo-or-die-python 0.1.1
File Size Uploaded
todo-or-die-python-0.1.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for todo-or-die-python 0.1.1
File Interpreter ABI Platform
todo_or_die_python-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.0 kB

Release files / todo-or-die-python-0.1.1.tar.gz

Download URL todo-or-die-python-0.1.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6b8abc1fc19747e7242490f6e17eda71563df0331a71c48a78de082464b99116
BLAKE2b-256 checksum
How to use checksums
7f971ff143ec9da93211cf946a1dbdaec31014ee446ce686df14b0acc7e48463
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release files / todo_or_die_python-0.1.1-py3-none-any.whl

Download URL todo_or_die_python-0.1.1-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdb55b00481cd6b040bbd0a2e373f33362b8a2591779799ef860df07e3bdfef6
BLAKE2b-256 checksum
How to use checksums
afe8fccb184242c03920972fb84021d4e2528d6a3e7a4666cc41f1c4ff020167
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page