Skip to content

Commit

Permalink
rename Method._is_unnamed -> is_unnamed + add docstring (#253)
Browse files Browse the repository at this point in the history
Make the Method.is_unnamed a public method + give it a docstring.
  • Loading branch information
fohrloop authored Apr 14, 2024
1 parent a06122e commit 2b068a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/wakepy/core/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def activate_method(method: Method) -> Tuple[MethodActivationResult, Heartbeat |
If the `method` has method.heartbeat() implemented, and activation
succeeds, this is a Heartbeat object. Otherwise, this is None.
"""
if method._is_unnamed():
if method.is_unnamed():
raise ValueError("Methods without a name may not be used to activate modes!")

result = MethodActivationResult(success=False, method_name=method.name)
Expand Down
9 changes: 8 additions & 1 deletion src/wakepy/core/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,14 @@ def __repr__(self) -> str:
return f"<wakepy Method: {self.__class__.__name__} at {hex(id(self))}>"

@classmethod
def _is_unnamed(cls) -> bool:
def is_unnamed(cls) -> bool:
"""Tells if the Method has a name or not. See also docs for
`Method.name`.
Returns
-------
True if the method is without a name. Otherwise False.
"""
return cls.name == unnamed


Expand Down
2 changes: 1 addition & 1 deletion src/wakepy/core/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MethodRegistryError(RuntimeError):
def register_method(method_class: Type[Method]) -> None:
"""Registers a subclass of Method to the method registry"""

if method_class._is_unnamed():
if method_class.is_unnamed():
# Methods without a name will not be registered
return

Expand Down

0 comments on commit 2b068a9

Please sign in to comment.