mirror of https://github.com/zulip/zulip.git
7657cb4a0f
django-stubs 4.2.1 gives transaction.on_commit a more accurate type annotation, but this exposed that mypy can’t handle the lambda default parameters that we use to recapture loop variables such as for stream_id in public_stream_ids: peer_user_ids = … event = … transaction.on_commit( lambda event=event, peer_user_ids=peer_user_ids: send_event( realm, event, peer_user_ids ) ) https://github.com/python/mypy/issues/15459 A workaround that mypy accepts is transaction.on_commit( ( lambda event, peer_user_ids: lambda: send_event( realm, event, peer_user_ids ) )(event, peer_user_ids) ) But that’s kind of ugly and potentially error-prone, so let’s make a helper function for this very common pattern. send_event_on_commit(realm, event, peer_user_ids) Signed-off-by: Anders Kaseorg <anders@zulip.com> |
||
---|---|---|
.. | ||
actions | ||
data_import | ||
integration_fixtures/nagios | ||
lib | ||
management | ||
migrations | ||
openapi | ||
tests | ||
tornado | ||
views | ||
webhooks | ||
worker | ||
__init__.py | ||
apps.py | ||
context_processors.py | ||
decorator.py | ||
filters.py | ||
forms.py | ||
logging_handlers.py | ||
middleware.py | ||
models.py | ||
signals.py |