Skip to content

Commit

Permalink
Pass excludes through the stack into the call to flake8
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <ryan_friedman@trimble.com>
  • Loading branch information
RFRIEDM-Trimble committed Nov 16, 2022
1 parent 0b86e54 commit 450789b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ament_cmake_flake8/cmake/ament_cmake_flake8_lint_hook.cmake
Expand Up @@ -15,5 +15,6 @@
file(GLOB_RECURSE _python_files FOLLOW_SYMLINKS "*.py")
if(_python_files)
message(STATUS "Added test 'flake8' to check Python code syntax and style conventions")
ament_flake8()
message(STATUS "Configured 'flake8' exclude dirs and/or files: ${AMENT_LINT_AUTO_FILE_EXCLUDE}")
ament_flake8(EXCLUDE ${AMENT_LINT_AUTO_FILE_EXCLUDE})
endif()
8 changes: 6 additions & 2 deletions ament_cmake_flake8/cmake/ament_flake8.cmake
Expand Up @@ -31,13 +31,15 @@
# :param MAX_LINE_LENGTH: override the maximum line length,
# the default is defined in ament_flake8
# :type MAX_LINE_LENGTH: integer
# :param EXCLUDE: an optional list of exclude directories or files for flake8
# :type EXCLUDE: list
# :param ARGN: the files or directories to check
# :type ARGN: list of strings
#
# @public
#
function(ament_flake8)
cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME;CONFIG_FILE" "" ${ARGN})
cmake_parse_arguments(ARG "" "EXCLUDE;MAX_LINE_LENGTH;TESTNAME;CONFIG_FILE" "" ${ARGN})
if(NOT ARG_TESTNAME)
set(ARG_TESTNAME "flake8")
endif()
Expand All @@ -57,7 +59,9 @@ function(ament_flake8)
if(ARG_MAX_LINE_LENGTH)
list(APPEND cmd "--linelength" "${ARG_MAX_LINE_LENGTH}")
endif()
list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS})
if(ARG_EXCLUDE)
list(APPEND cmd "--exclude" "${ARG_EXCLUDE}")
endif()

file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_flake8")
ament_add_test(
Expand Down

0 comments on commit 450789b

Please sign in to comment.