Skip to main content

Halt code if your TODO is passed due

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

todo-or-die-python-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

todo_or_die_python-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file todo-or-die-python-0.1.1.tar.gz.

File metadata

  • Download URL: todo-or-die-python-0.1.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for todo-or-die-python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6b8abc1fc19747e7242490f6e17eda71563df0331a71c48a78de082464b99116
MD5 7a1423da12ef37f177da057cc3334ebd
BLAKE2b-256 7f971ff143ec9da93211cf946a1dbdaec31014ee446ce686df14b0acc7e48463

See more details on using hashes here.

File details

Details for the file todo_or_die_python-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: todo_or_die_python-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for todo_or_die_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fdb55b00481cd6b040bbd0a2e373f33362b8a2591779799ef860df07e3bdfef6
MD5 e871a44114476e1c1cdd71c9a14a650a
BLAKE2b-256 afe8fccb184242c03920972fb84021d4e2528d6a3e7a4666cc41f1c4ff020167

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page