Skip to content

Commit

Permalink
fix(decorator): reject wrapper as dunder methods (#5030)
Browse files Browse the repository at this point in the history
fix(decorator): gated wrapper to not support dunder methods

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
  • Loading branch information
aarnphm authored Oct 17, 2024
1 parent d8b6ef8 commit b696903
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/_bentoml_sdk/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def api(
"""

def wrapper(func: t.Callable[t.Concatenate[t.Any, P], R]) -> APIMethod[P, R]:
if func.__name__.startswith("__"):
raise ValueError("API methods cannot start with '__'")
params: dict[str, t.Any] = {
"batchable": batchable,
"batch_dim": batch_dim,
Expand Down Expand Up @@ -182,6 +184,8 @@ def task(
"""

def wrapper(func: t.Callable[t.Concatenate[t.Any, P], R]) -> APIMethod[P, R]:
if func.__name__.startswith("__"):
raise ValueError("API methods cannot start with '__'")
params: dict[str, t.Any] = {
"batchable": batchable,
"batch_dim": batch_dim,
Expand Down

0 comments on commit b696903

Please sign in to comment.