Skip to content

Commit 0b45722

Browse files
committed
Fix cryptic error for 2.x deploy decorators broken in 3.x
Now raises a readable exception with link to the compatability notes.
1 parent dade4d2 commit 0b45722

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pyinfra/api/deploy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ def deploy(name: Optional[str] = None, data_defaults=None):
6060
and wraps any operations called inside with any deploy-wide kwargs/data.
6161
"""
6262

63+
if name and not isinstance(name, str):
64+
raise PyinfraError(
65+
(
66+
"The `deploy` decorator must be called, ie `@deploy()`, "
67+
"see: https://docs.pyinfra.com/en/3.x/compatibility.html#upgrading-pyinfra-from-2-x-3-x"
68+
)
69+
)
70+
6371
def decorator(func: Callable[P, Any]) -> PyinfraOperation[P]:
6472
func.deploy_name = name or func.__name__ # type: ignore[attr-defined]
6573
if data_defaults:

0 commit comments

Comments
 (0)