Skip to content

Commit

Permalink
flake8 runs without errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SCHREIBER Martin committed Nov 13, 2024
1 parent b9b24a3 commit 12a1aa7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
Binary file added bin_git/.run_flake8.sh.swp
Binary file not shown.
43 changes: 43 additions & 0 deletions bin_git/run_flake8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd "$SCRIPTPATH/.."

# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
#
# This script ensures that the whole of PSyclone is linted successfully
# before the push is executed.

remote="$1"
url="$2"

if ! command -v flake8; then
echo "WARNING: source not linted because flake8 unavailable"
exit 0
fi


flake8 src/psyclone

if [[ $? -ne 0 ]]; then
echo "Linting failed"
exit 1
else
echo "Linting succeeded"
fi

exit 0
13 changes: 7 additions & 6 deletions src/psyclone/psyir/nodes/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
RoutineSymbol, Symbol, SymbolError, UnsupportedFortranType, DataSymbol)
from typing import List


class Call(Statement, DataNode):
''' Node representing a Call. This can be found as a standalone statement
or an expression.
Expand Down Expand Up @@ -594,7 +595,7 @@ def _location_txt(node):
f" is within a CodeBlock.")

class MatchingArgumentsNotFound(BaseException):
"""Excepction to signal that matching arguments have not been found
"""Excepction to signal that matching arguments have not been found
for this routine
"""

Expand Down Expand Up @@ -652,7 +653,7 @@ def get_argument_routine_match(self, routine: Routine):
f"'{call_arg}' and routine argument "
f"'{routine_arg}'"
)

ret_arg_idx_list.append(call_arg_idx)
routine_argument_list[call_arg_idx] = None
continue
Expand Down Expand Up @@ -684,18 +685,18 @@ def get_argument_routine_match(self, routine: Routine):
f"'{call_arg}' and routine argument "
f"'{routine_arg}'"
)

ret_arg_idx_list.append(routine_arg_idx)
named_arg_found = True
break

if not named_arg_found:
# It doesn't match => Raise exception
raise self.MatchingArgumentsNotFound

if routine_arg_idx is None:
raise IndexError("Internal error")

routine_argument_list[routine_arg_idx] = None

#
Expand Down Expand Up @@ -761,4 +762,4 @@ def get_callee(
return routine_list[0]

raise NotImplementedError(f"No matching routine for call "
f"'{self.routine.name}' found")
f"'{self.routine.name}' found")
20 changes: 10 additions & 10 deletions src/psyclone/tests/psyir/nodes/call_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def test_call_get_callee_1_simple_match(fortran_reader):
call_foo: Call = routine_main.walk(Call)[0]

result = call_foo.get_callee()

routine_match: Routine = psyir.walk(Routine)[1]
assert result is routine_match

Expand Down Expand Up @@ -701,7 +701,7 @@ def test_call_get_callee_2_optional_args(fortran_reader):
assert len(arg_idx_list) == 2
assert arg_idx_list[0] == 0
assert arg_idx_list[1] == 1

assert result is routine_match


Expand Down Expand Up @@ -788,7 +788,7 @@ def test_call_get_callee_4_named_arguments(fortran_reader):
assert arg_idx_list[0] == 2
assert arg_idx_list[1] == 0
assert arg_idx_list[2] == 1

assert result is routine_match


Expand Down Expand Up @@ -831,7 +831,7 @@ def test_call_get_callee_5_optional_and_named_arguments(fortran_reader):
assert len(arg_idx_list) == 2
assert arg_idx_list[0] == 1
assert arg_idx_list[1] == 0

assert result is routine_match


Expand All @@ -858,7 +858,7 @@ def test_call_get_callee_6_interfaces(fortran_reader):
! Should match foo_a
call foo(e_int, f_int, g_int)
! Should match foo_b
call foo(e_real, f_int)
Expand All @@ -868,7 +868,7 @@ def test_call_get_callee_6_interfaces(fortran_reader):
! Should match foo_b
call foo(e_real, c=f_int, b=g_int)
! Should match foo_c
call foo(e_int, f_real, g_int)
Expand Down Expand Up @@ -945,7 +945,7 @@ def test_call_get_callee_6_interfaces(fortran_reader):

assert result is routine_foo_a
print(" - Passed subtest foo_a[1]")

if 1:
routine_foo_b: Routine = root_node.walk(Routine)[2]
assert routine_foo_b.name == "foo_b"
Expand All @@ -955,7 +955,7 @@ def test_call_get_callee_6_interfaces(fortran_reader):

call_foo_b: Call = routine_main.walk(Call)[2]
assert call_foo_b.routine.name == "foo"

arg_idx_list = []
result: Routine = call_foo_b.get_callee(
ret_arg_match_list=arg_idx_list)
Expand All @@ -974,7 +974,7 @@ def test_call_get_callee_6_interfaces(fortran_reader):

call_foo_b: Call = routine_main.walk(Call)[3]
assert call_foo_b.routine.name == "foo"

arg_idx_list = []
result: Routine = call_foo_b.get_callee(
ret_arg_match_list=arg_idx_list)
Expand All @@ -994,7 +994,7 @@ def test_call_get_callee_6_interfaces(fortran_reader):

call_foo_b: Call = routine_main.walk(Call)[4]
assert call_foo_b.routine.name == "foo"

arg_idx_list = []
result: Routine = call_foo_b.get_callee(
ret_arg_match_list=arg_idx_list)
Expand Down

0 comments on commit 12a1aa7

Please sign in to comment.