Changelog¶
1.0.1 (2026-11-16)¶
Fixed:
- Side-effect reports and recursion chains name a decorated receiver after
its function, not the decorator's wrapper (such as
disable_for_loaddata.<locals>.wrapper), when the decorator usesfunctools.wraps.IGNORE_RECEIVERSand baselines now see the real name, so receivers that share a decorator are told apart. A receiver of yours behind a decorator from an installed package was taken for library code, and its side effects went unreported; they are reported now. - Paths in reports stay relative to the project for code compiled on another
machine. pytest before 9.2 reuses the rewritten test modules it cached on
the host, so a baseline written in a container that mounts the project
could get host paths such as
/Users/me/project/conftest.py, which match nowhere else.
If your baseline has entries naming a <locals>.wrapper receiver or an
absolute path, regenerate it after upgrading:
pytest --signal-guard-baseline=FILE --signal-guard-update-baseline.
1.0.0 (2026-11-13)¶
The first stable release. From here on, the public API follows semantic versioning: see the stability policy.
Changed defaults (see upgrading to 1.0):
LIBRARY_RECEIVERSis now"ignore_global": receivers from installed packages connected for every sender (easy_thumbnails, imagekit and the like) no longer make every bulk write report. Set"report"for the 0.x behaviour.IGNORE_HISTORICAL_MODELSis nowTrue: bulk writes in data migrations are not checked. SetFalsefor the 0.x behaviour.
Added:
signal_guard.testing, assertions for tests:capture_reports(),assert_no_reports(),assert_bypass(),assert_side_effect()andassert_recursion(), which collect reports instead of raising, warning or logging them;capture_signals(),assert_sent()andassert_not_sent(), which record the signals sent and their arguments;assert_connected()andassert_not_connected();- pytest fixtures
signal_reportsandsent_signals, andSignalGuardAssertionsMixinforunittesttest cases. - A baseline for adopting the guard on an existing codebase:
pytest --signal-guard-baseline=FILEsilences the reports listed in FILE and fails the run on new ones;--signal-guard-update-baselinewrites it. Also as thesignal_guard_baselineini option. Works with pytest-xdist. - Reports carry
where(path::function), a stablefingerprintand theerrorwith structured details. benchmarks/overhead.py, run in CI, measures what each wrapper adds.- Documentation at https://panosangelopoulos.github.io/django-signal-guard/.
Changed:
- Settings are read once and again when
setting_changedis sent (as byoverride_settingsand pytest-django'ssettingsfixture), instead of on every call. A bulk write on a model with receivers costs about 2 µs less. - Bulk writes on models without save receivers skip the guard sooner.
- The package's own modules never count as first-party, even when installed in editable mode.
0.4.0 (2026-11-13)¶
Added, all off by default, to cut noise on large projects:
LIBRARY_RECEIVERS:"ignore_global"stops the bypass guard reporting receivers from installed packages connected for every sender, such as easy_thumbnails' and imagekit's;"ignore"skips all library receivers.IGNORE_HISTORICAL_MODELS: skip bulk writes on the historical models migrations use.IGNORE_CREATE_ONLY_RECEIVERS: forupdate()andbulk_update(), skippost_savereceivers whose source shows they only act whencreated. A heuristic.IGNORE_RECEIVER_SELF_UPDATES: skip bulk writes apre_saveorpost_savereceiver makes to its own model.
Also added:
allow_side_effect(reason=...), a context manager and decorator that allows side effects before commit, likeallow_bypassdoes for bulk writes.- A pytest plugin:
pytest --signal-guard-summarylists reports by call site, with counts and the tests that hit them. Works with pytest-xdist. - Log records carry
signal_guard_kind,signal_guard_locationandsignal_guard_test(the running pytest node id). SkippedReceiverhasmodule,any_senderandcreate_only.
Changed (report text only; what gets reported is unchanged unless noted):
- A task queued from a
pre_deleteorpost_deletereceiver is reported with advice thaton_commit()alone won't help, since the row is gone by then. - Bypass reports mark receivers that look create-only with
[create-only?], and say when the write runs inside a save receiver for the same model. - A manager or queryset that overrides
update(),bulk_update()orbulk_create()is no longer reported as the call site; the caller is, with the override after "through". When the override was in an installed package, these writes used to be skipped as library calls; they are now reported. - Side-effect reports blame the first line of your own code inside the receiver, not a line in a vendor SDK it called.
Fixed:
- Paths in reports are relative to the project even when a file was reached
through a symlink or another spelling of the folder, and relative to
settings.BASE_DIRwhen the current folder is outside it.
0.3.0 (2026-11-13)¶
- Recursion tracing: a receiver that sends the same signal for the same
object while it is already being handled twice is reported with the whole
chain, such as a
post_savereceiver that callsinstance.save(). New settingRECURSION,SignalRecursionErrorandSignalRecursionWarning. @receiver_on_commit: like@receiver, but runs the receiver throughtransaction.on_commit()with the arguments the signal sent.- Side effects before commit: email, Celery tasks,
requestsandhttpxcalls made by a receiver inside a transaction that has not committed are reported. Transactions opened byTestCasedo not count. New settingsSIDE_EFFECTSandSIDE_EFFECT_CALLS,SideEffectBeforeCommitErrorandSideEffectBeforeCommitWarning. @bulk_safeworks on either side of@receiver_on_commit; system checks W001 and W004, the registry andsignal_mapsee through its wrapper.IGNORE_RECEIVERSandCHECK_LIBRARY_CALLSapply to the new checks.
0.2.0 (2026-11-13)¶
- System checks, tag
signals: - W001: a module defines
@receiverfunctions but is never imported. - W002: a receiver is connected only after startup, by a lazy import.
- W003: a weakly connected function or lambda was garbage-collected.
- W004: the same receiver is connected more than once.
manage.py signal_map, with--all,--writeand--checkfor a committedsignals.lockfile.- A registry of
connect()anddisconnect()calls behind the checks. - New settings
FIRST_PARTYandLOCK_FILE. - Changed:
CHECK_DJANGO_INTERNALSis nowCHECK_LIBRARY_CALLSand also skips bulk writes made inside installed packages, not only Django. - Fixed: never ask a lazy object for its class while looking for signals.
0.1.0 (not published)¶
First release: the bypass guard.
- Wraps
QuerySet.bulk_create(),bulk_update()andupdate()(and their async variants) and reports livepre_save/post_savereceivers they would skip. - Modes
raise,warn,logandoffviaSIGNAL_GUARD['BYPASS']. allow_bypass(*models, reason=...)as a context manager, decorator andasync with.@bulk_safemarker andIGNORE_RECEIVERSpatterns.- Bulk writes made by Django itself are skipped unless
CHECK_DJANGO_INTERNALSis on (renamed in 0.2.0).