Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions hathor/nanocontracts/resources/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,21 @@ def render_GET(self, request: 'Request') -> bytes:
continue

method_args = []
argspec = inspect.getfullargspec(method)
for arg_name in argspec.args[1:]:
arg_type = argspec.annotations[arg_name]
signature = inspect.signature(method)
for parameter in signature.parameters.values():
if parameter.name == 'self':
continue
arg_type = parameter.annotation
if arg_type is Context:
continue
method_args.append(MethodArgInfo(
name=arg_name,
name=parameter.name,
type=self.get_type_name(arg_type),
))

return_type = argspec.annotations.get('return', None)
return_type = signature.return_annotation
if return_type is inspect._empty:
return_type = None

method_info = MethodInfo(
args=method_args,
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/nanocontracts/my_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MyBlueprint(Blueprint):
a_optional_int: Optional[int]

@public
def initialize(self, ctx: Context) -> None:
def initialize(self, ctx: Context, arg1: int) -> None:
pass

@public
Expand Down
5 changes: 4 additions & 1 deletion tests/resources/nanocontracts/test_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def test_success(self) -> Generator[Deferred[Any], Any, None]:
})
self.assertEqual(data['public_methods'], {
'initialize': {
'args': [],
'args': [{
'name': 'arg1',
'type': 'int',
}],
'return_type': 'null',
'docstring': None,
},
Expand Down