Skip to content

Commit

Permalink
codecov fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Masara committed Aug 17, 2024
1 parent 3e541f9 commit 89d42a9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 25 deletions.
48 changes: 23 additions & 25 deletions src/safeds_stubgen/api_analyzer/_ast_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,36 +597,34 @@ def _remove_assignments(func_defn: list, type_: AbstractType) -> AbstractType:
found_types = [type_]

for found_type in found_types:
if not isinstance(found_type, sds_types.NamedType):
continue

is_assignment = False
found_type_name = found_type.name

for defn in func_defn:
if not isinstance(defn, mp_nodes.AssignmentStmt):
continue

for lvalue in defn.lvalues:
if isinstance(lvalue, mp_nodes.TupleExpr):
name_expressions = lvalue.items
else:
name_expressions = [lvalue]

for expr in name_expressions:
if isinstance(expr, mp_nodes.NameExpr) and found_type_name == expr.name:
is_assignment = True
if isinstance(found_type, sds_types.NamedType):
is_assignment = False
found_type_name = found_type.name

for defn in func_defn:
if not isinstance(defn, mp_nodes.AssignmentStmt):
continue

for lvalue in defn.lvalues:
if isinstance(lvalue, mp_nodes.TupleExpr):
name_expressions = lvalue.items
else:
name_expressions = [lvalue]

for expr in name_expressions:
if isinstance(expr, mp_nodes.NameExpr) and found_type_name == expr.name:
is_assignment = True
break
if is_assignment:
break

if is_assignment:
break

if is_assignment:
break

if is_assignment:
actual_types.append(sds_types.UnknownType())
else:
actual_types.append(found_type)
actual_types.append(sds_types.UnknownType())
else:
actual_types.append(found_type)

if len(actual_types) > 1:
type_ = sds_types.TupleType(types=actual_types)
Expand Down
5 changes: 5 additions & 0 deletions tests/data/various_modules_package/function_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,8 @@ def _f(x: int, y: int) -> int:
g, f = _f(a, b)
Cxy = _f(g, f)**2
return Cxy, f


def ignore_assignment2(a: int, b: int):
Cxy = 3**2
return Cxy
23 changes: 23 additions & 0 deletions tests/safeds_stubgen/api_analyzer/__snapshots__/test__get_api.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -6094,6 +6094,28 @@
'tests/data/various_modules_package/function_module/ignore_assignment/result_2',
]),
}),
dict({
'docstring': dict({
'description': '',
'examples': list([
]),
'full_docstring': '',
}),
'id': 'tests/data/various_modules_package/function_module/ignore_assignment2',
'is_class_method': False,
'is_property': False,
'is_public': True,
'is_static': False,
'name': 'ignore_assignment2',
'parameters': list([
'tests/data/various_modules_package/function_module/ignore_assignment2/a',
'tests/data/various_modules_package/function_module/ignore_assignment2/b',
]),
'reexported_by': list([
]),
'results': list([
]),
}),
dict({
'docstring': dict({
'description': '',
Expand Down Expand Up @@ -7571,6 +7593,7 @@
'tests/data/various_modules_package/function_module/result_from_outside_the_package',
'tests/data/various_modules_package/function_module/ret_conditional_statement',
'tests/data/various_modules_package/function_module/ignore_assignment',
'tests/data/various_modules_package/function_module/ignore_assignment2',
]),
'id': 'tests/data/various_modules_package/function_module',
'name': 'function_module',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ fun ignoreAssignment(
b: Int
) -> (result1: unknown, result2: unknown)

// TODO Result type information missing.
@Pure
@PythonName("ignore_assignment2")
fun ignoreAssignment2(
a: Int,
b: Int
)

class FunctionModuleClassA()

// TODO Some parameter have no type information.
Expand Down

0 comments on commit 89d42a9

Please sign in to comment.