Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore: generate warnings for events that will be removed in Juju 4.0 #1374

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ops/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import enum
import logging
import pathlib
import warnings
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -359,6 +360,14 @@ class PreSeriesUpgradeEvent(HookEvent):
.. jujuremoved:: 4.0
"""

def __init__(self, handle: 'Handle'):
warnings.warn(
'pre-series-upgrade events will not be emitted from Juju 4.0 onwards',
DeprecationWarning,
stacklevel=3,
)
super().__init__(handle)


class PostSeriesUpgradeEvent(HookEvent):
"""Event triggered after a series upgrade.
Expand All @@ -375,6 +384,14 @@ class PostSeriesUpgradeEvent(HookEvent):
.. jujuremoved:: 4.0
"""

def __init__(self, handle: 'Handle'):
warnings.warn(
'post-series-upgrade events will not be emitted from Juju 4.0 onwards',
DeprecationWarning,
stacklevel=3,
)
super().__init__(handle)


class LeaderElectedEvent(HookEvent):
"""Event triggered when a new leader has been elected.
Expand Down Expand Up @@ -412,6 +429,15 @@ class CollectMetricsEvent(HookEvent):
.. jujuremoved:: 4.0
"""

def __init__(self, handle: 'Handle'):
warnings.warn(
'collect-metrics events will not be emitted from Juju 4.0 onwards - '
'consider using the Canonical Observability Stack',
DeprecationWarning,
stacklevel=3,
)
super().__init__(handle)

def add_metrics(
self, metrics: Mapping[str, Union[int, float]], labels: Optional[Mapping[str, str]] = None
):
Expand Down
Loading