<@ULVA73B9P> I'm trying to load a PagerDutyWebhook...
# ask-community
b
@Marvin I'm trying to load a PagerDutyWebhook block in my flow code that I created in Prefect Cloud UI:
Copy code
from prefect.blocks.notifications import PagerDutyWebhook
pagerduty_webhook_block = PagerDutyWebhookBlock.load("my-pager-duty-block)
I'm getting this error:
Copy code
File ".venv/lib/python3.13/site-packages/prefect/blocks/notifications.py", line 41, in __init__ NOTIFY_TYPES += (PREFECT_NOTIFY_TYPE_DEFAULT, ) # pyright: ignore[reportUnknownVariableType]
TypeError: unsupported operand type(s) for +=: 'frozenset' and 'tuple'
I'm using prefect version 3.4.0 Any suggestions?
m
thought for 238.1 seconds
Thanks for the details — this is a known incompatibility between Prefect 3.4.0’s notifications module and newer versions of the Apprise library. What’s happening - Prefect’s notifications module tries to extend Apprise’s NOTIFY_TYPES like
NOTIFY_TYPES += (...)
. - Newer Apprise versions changed
NOTIFY_TYPES
to a
frozenset
(immutable), so the
+=
throws
TypeError: unsupported operand type(s) for +=: 'frozenset' and 'tuple'
. Also, a quick naming note: in Prefect 3.x the class is
PagerDutyWebHook
(capital H) and there is no
PagerDutyWebhookBlock
class name. Loading the block should look like this:
Copy code
from prefect.blocks.notifications import PagerDutyWebHook

pd = PagerDutyWebHook.load("my-pager-duty-block")
How to fix - Best fix: upgrade to the latest Prefect 3.4.x, which includes multiple compatibility improvements and bugfixes. -
pip install -U prefect
- Release notes: Prefect releases - If you need to stay on Prefect 3.4.0: pin Apprise to an earlier version where
NOTIFY_TYPES
was still mutable. I don’t want to guess the exact version without your environment details — could you share
pip show apprise
? I can confirm a safe pin once I know the version you’re on. Reference docs - Blocks in Prefect 3: Blocks concept docs If you upgrade Prefect and still see the error, let me know your Apprise version and I’ll suggest a precise pin.
b
@Marvin
Copy code
Name: apprise
Version: 1.9.5
Summary: Push Notifications that work with just about every platform!
Requires: certifi, click, markdown, PyYAML, requests, requests-oauthlib
Required-by: prefect
m
thought for 64.1 seconds
Thanks — that traceback is caused by a change in the Apprise library: in newer Apprise versions,
NOTIFY_TYPES
is a frozenset (immutable), and Prefect 3.4.0’s notifications module tries to extend it with
+=
, which raises the TypeError you’re seeing. Also, a quick naming fix: in Prefect 3.x the class is
PagerDutyWebHook
(capital H), and you load it directly from the class (there’s no
PagerDutyWebhookBlock
class). For example:
Copy code
from prefect.blocks.notifications import PagerDutyWebHook

pd = PagerDutyWebHook.load("my-pager-duty-block")
You’re on Apprise 1.9.5. Here are two ways to get unblocked: - Option A: Upgrade Prefect to the latest 3.4.x - This includes various compatibility improvements and may avoid this issue. - Command:
Copy code
pip install -U prefect
- Releases: Prefect releases - Option B: Pin Apprise below 1.9.5 (roll back the change that made
NOTIFY_TYPES
immutable) - Command:
Copy code
pip install "apprise<1.9.5"
- If you still hit the error, try an earlier minor series:
Copy code
pip install "apprise>=1.8,<1.9"
Docs for reference: Blocks in Prefect 3 Give one of those a try and let me know if the error persists. If you prefer not to change Prefect right now, pinning Apprise below 1.9.5 is the quickest workaround.