Skip to content

Commit

Permalink
Fix cryptic error for 2.x deploy decorators broken in 3.x
Browse files Browse the repository at this point in the history
Now raises a readable exception with link to the compatability notes.
  • Loading branch information
Fizzadar committed Sep 25, 2024
1 parent dade4d2 commit 0b45722
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pyinfra/api/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ def deploy(name: Optional[str] = None, data_defaults=None):
and wraps any operations called inside with any deploy-wide kwargs/data.
"""

if name and not isinstance(name, str):
raise PyinfraError(
(
"The `deploy` decorator must be called, ie `@deploy()`, "
"see: https://docs.pyinfra.com/en/3.x/compatibility.html#upgrading-pyinfra-from-2-x-3-x"
)
)

def decorator(func: Callable[P, Any]) -> PyinfraOperation[P]:
func.deploy_name = name or func.__name__ # type: ignore[attr-defined]
if data_defaults:
Expand Down

0 comments on commit 0b45722

Please sign in to comment.