cinder/tools/mypywrap.sh
Brian Rosmaita c8c4fc953c Add installation of mypy stubs packages
The cinder-mypy job is failing because library stubs aren't installed
for requests [0].  Modify the mypywrap.sh to accept options specified
in an environment variable named OS_MYPY_OPTS to the mypy invocation,
and set this var in tox.ini.

The value is "--install-types --non-interactive" which is suitable for
CI purposes, and seems to make sense for local tox use as well [1].
The downside is it basically runs mypy twice, once to determine
whether there are any library stubs missing and then install them, and
againto do the actual check.  If we don't want this setting in
tox.ini, we can move it to .zuul.yaml for the cinder-mypy job run.

Also, update the version of mypy in test-requirements to a version
that supports the above options.

And, run mypy in its own env (instead of reusing pep8) so that the
tox logs are preserved during CI runs.

[0] https://zuul.opendev.org/t/openstack/build/b66ee6c21e594940941585b0e9e5082a
[1] https://mypy.readthedocs.io/en/stable/running_mypy.html#library-stubs-not-installed

Change-Id: Id69cb519ee7300b33ff087de4e7d46cdad67d162
2021-07-15 10:33:36 -04:00

25 lines
744 B
Bash
Executable File

#!/bin/bash
#
# A wrapper around mypy that allows us to specify what files to run 'mypy' type
# checks on. Intended to be invoked via tox:
#
# tox -e mypy
#
# Eventually this should go away once we have either converted everything or
# converted enough and ignored [1] the rest.
#
# [1] http://mypy.readthedocs.io/en/latest/config_file.html#per-module-flags
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export MYPYPATH=$ROOT_DIR/../cinder/tests/stubs/
if [ $# -eq 0 ]; then
# if no arguments provided, use the standard converted lists
lines=$(grep -v '#' $ROOT_DIR/../mypy-files.txt)
python -m mypy $OS_MYPY_OPTS ${lines[@]}
else
# else test what the user asked us to
python -m mypy $OS_MYPY_OPTS $@
fi