Skip to content

Commit

Permalink
Incorporate feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
devennavani committed May 8, 2024
1 parent 328fdcd commit da7aaf5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def wrapped(

# Check if the decorated object is a class
if inspect.isclass(f):
raise TypeError("The @app.function decorator cannot be used on a class.")
raise TypeError("The @app.function decorator cannot be used on a class. Please use @app.cls instead.")

if isinstance(f, _PartialFunction):
f.wrapped = True
Expand Down
4 changes: 1 addition & 3 deletions test/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,12 @@ def f():

def test_function_decorator_on_class():
app = App()
with pytest.raises(TypeError) as excinfo:
with pytest.raises(TypeError, match="cannot be used on a class"):

@app.function()
class Foo:
pass

assert "cannot be used on a class" in str(excinfo.value)


@pytest.mark.asyncio
async def test_deploy_disconnect(servicer, client):
Expand Down

0 comments on commit da7aaf5

Please sign in to comment.