Skip to content

Commit

Permalink
Fix an edge case with multiples param being the first one "self"
Browse files Browse the repository at this point in the history
  • Loading branch information
msaelices committed Sep 10, 2023
1 parent 69cd1c1 commit ac770fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion py2mojo/converters/functiondef.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def convert_functiondef(node: ast.FunctionDef, level: int = 0) -> Iterable:
new_type = get_mojo_type(curr_type)

if not new_type:
return
continue

yield (
ast_to_offset(arg),
Expand Down
11 changes: 11 additions & 0 deletions tests/test_functiondef.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ def test_functiondef_with_list_types():
'def concat(l1: list, l2: list) -> list: return l1 + l2', # no changed
)

def test_functiondef_inside_classes():
validate(
'''
class Point:
def __init__(self, x: int, y: int) -> int: ...
''',
'''
class Point:
def __init__(self, x: Int, y: Int) -> Int: ...
''',
)

0 comments on commit ac770fd

Please sign in to comment.