Skip to content

Commit

Permalink
Cleaner user facing documentation and deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garner-canonical committed Sep 22, 2024
1 parent f2ff4ba commit 0782be2
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions ops/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1941,27 +1941,8 @@ def from_name(cls, name: str, message: str):

@classmethod
def register(cls, child: Type['StatusBase']):
"""Class decorator to register a subclass for lookup using :meth:`from_name`.
Note: this method is deprecated. Registration is now automatic via __init_subclass.
Also, this decorator obscures the class type when used as a decorator.
Note: this method is intended for internal use only.
It is used to make the valid Juju statuses available by name.
Args:
child: A subclass of StatusBase, with a ``name`` attribute of type ``str``.
Returns:
The decorated class, unmodified.
"""
warnings.warn(
'StatusBase.register should not be called. It is intended'
'for internal use only and is superseded by automatic subclass'
'registration via __init_subclass__',
DeprecationWarning,
stacklevel=2,
)
""".. deprecated:: 2.17.0 Deprecated - this was for internal use only."""
warnings.warn('StatusBase.register is for internal use only', DeprecationWarning)
cls._register(child)
return child

Expand Down

0 comments on commit 0782be2

Please sign in to comment.