Skip to content

Commit

Permalink
feat(build): fluidattacks#1176 lint python
Browse files Browse the repository at this point in the history
- Add mypy_status and mypy_status variables
  • Loading branch information
eavelasquez committed Jan 31, 2024
1 parent 9f93d14 commit d45f666
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/args/lint-python/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function main {
local python_dirs
local python_dir

local mypy_status=0
local prospector_status=0

package_name="$(basename "${envSrc#*-}")" \
&& info Running mypy over: "${package_path}", package "${package_name}" \
&& if ! test -e "${package_path}/py.typed"; then
Expand All @@ -20,7 +23,7 @@ function main {
&& tmpdir="$(mktemp -d)" \
&& copy "${package_path}" "${tmpdir}/${package_name}" \
&& pushd "${tmpdir}" \
&& mypy --config-file "${envSettingsMypy}" "${package_name}" \
&& mypy --config-file "${envSettingsMypy}" "${package_name}" || mypy_status=$? \
&& python_dirs=() \
&& current_python_dir="" \
&& find . -name '*.py' > tmp \
Expand All @@ -34,19 +37,21 @@ function main {
done < tmp \
&& for dir in "${python_dirs[@]}"; do
info Running mypy over: "${package_path}", folder "${dir}" \
&& mypy --config-file "${envSettingsMypy}" "${dir}" \
|| return 1
&& mypy --config-file "${envSettingsMypy}" "${dir}" || mypy_status=$?
done \
&& popd \
&& info Running prospector over: "${package_path}", package "${package_name}" \
&& if ! test -e "${package_path}/__init__.py"; then
error This is not a python package, a package has __init__.py
fi \
&& pushd "${tmpdir}" \
&& prospector --profile "${envSettingsProspector}" "${package_name}" \
&& prospector --profile "${envSettingsProspector}" "${package_name}" || prospector_status=$? \
&& popd \
&& touch "${out}" \
|| return 1
&& touch "${out}"

if [ "$mypy_status" -ne 0 ] || [ "$prospector_status" -ne 0 ]; then
return 1
fi
}

main "${@}"

0 comments on commit d45f666

Please sign in to comment.