Skip to content

Commit

Permalink
fix: fix incorrect error message on unsupported class declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
achidlow committed Apr 5, 2024
1 parent 6beb29d commit 8eb5a78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/puya/awst_build/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ def visit_class_def(self, cdef: mypy.nodes.ClassDef) -> StatementResult:
return [lambda ctx: ContractASTConverter.convert(ctx, cdef, class_options)]
else:
self._error(
f"not a subclass of {constants.CONTRACT_BASE_ALIAS}"
f" or a direct subclass of {constants.STRUCT_BASE_ALIAS}",
f"Unsupported class declaration."
f" Contract classes must inherit either directly"
f" or indirectly from {constants.CONTRACT_BASE_ALIAS}.",
location=cdef,
)
return []
Expand Down
2 changes: 1 addition & 1 deletion tests/test_expected_output/module.test
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AllowedContract(Contract):
def clear_state_program(self) -> UInt64:
return UInt64(1)

class NotAllowed: ## E: not a subclass of algopy.Contract or a direct subclass of algopy.Struct
class NotAllowed: ## E: Unsupported class declaration. Contract classes must inherit either directly or indirectly from algopy.Contract.
pass

## case: all_ignored
Expand Down

0 comments on commit 8eb5a78

Please sign in to comment.