Skip to content

Commit b89b874

Browse files
committed
feat: MelleaSession.powerup
1 parent 3ef668b commit b89b874

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mellea/stdlib/session.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import contextvars
6+
import inspect
67
from copy import copy
78
from typing import Any, Literal, overload
89

@@ -804,6 +805,12 @@ async def atransform(
804805
self.ctx = context
805806
return result
806807

808+
@classmethod
809+
def powerup(cls, powerup_cls: type):
810+
"""Appends methods in a class object `powerup_cls` to MelleaSession."""
811+
for name, fn in inspect.getmembers(powerup_cls, predicate=inspect.isfunction):
812+
setattr(cls, name, fn)
813+
807814
# ###############################
808815
# Convenience functions
809816
# ###############################

0 commit comments

Comments
 (0)