Zero-Code Runtime Suppression.
A .gitignore-style workflow for disabling debug, development, and runtime behaviors in Python automatically. One import. Zero code changes. Full control.
What is this?
debugignore lets you declare which runtime behaviors (like prints, logging calls, debug helpers, network requests, or file writes) should be silently suppressed.
You define these rules in a simple .debugignore file that lives in your project root. When your app runs, debugignore intercepts these actions dynamically without throwing errors.
None or act as a noop, ensuring your application doesn't crash even if the underlying function is removed.
Before & After Examples
Below are real-world scenarios demonstrating how debugignore intercepts Python execution seamlessly.
1. Suppressing Prints
Console prints are the most common debugging tool, but leaving them in production can clutter logs. Here's how to disable them completely.
# app.py
def process_data():
print("Starting process...")
# ... doing work ...
print("Process finished!")
process_data()
Starting process...
Process finished!
# .debugignore
print
# app.py
import debugignore
def process_data():
print("Starting process...")
# ... doing work ...
print("Process finished!")
process_data()
(No output generated)
2. Disabling Module Functions (e.g., JSON)
You can target specific modules and functions. If you use a helper that dumps JSON to the console during dev, disable it entirely via wildcards.
# app.py
import json
data = {"user_id": 42, "status": "active"}
result = json.dumps(data)
print(f"Payload: {result}")
Payload: {"user_id": 42, "status": "active"}
# .debugignore
json.dumps
# app.py
import json
import debugignore
data = {"user_id": 42, "status": "active"}
result = json.dumps(data) # Returns None
print(f"Payload: {result}")
Payload: None
3. Blocking Network Requests
Ensure your test scripts or development environments don't accidentally ping production servers by blocking outbound HTTP requests.
# app.py
import requests
# Sends real data to a server
requests.post("https://api.example.com", json={"foo": "bar"})
print("Sent webhook!")
Sent webhook!
(Server receives HTTP POST)
# .debugignore
requests.post
# app.py
import requests
import debugignore
# Suppressed safely, returns a noop object
requests.post("https://api.example.com", json={"foo": "bar"})
print("Sent webhook!")
Sent webhook!
(No actual network request made)
4. Preventing File Writes
Disable file writes to avoid cluttering your filesystem during tests, while keeping file reads intact.
# app.py
with open("test.log", "w") as f:
f.write("System initialized.\n")
print("Log written.")
Log written.
(test.log is created on disk)
# .debugignore
open
*.write
# app.py
import debugignore
# File creation is intercepted.
# f is replaced by a dummy in-memory string buffer.
with open("test.log", "w") as f:
f.write("System initialized.\n")
print("Log written.")
Log written.
(No file is created on disk)
debugignore today and clean up your runtime behaviors effortlessly!