mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Remove wildcard imports and get_exception calls
Fixed module_utils
This commit is contained in:
parent
93e1caccb7
commit
ac56a2f138
15 changed files with 174 additions and 218 deletions
|
@ -3,7 +3,7 @@
|
|||
metaclass1=$(find ./bin -type f -exec grep -HL '__metaclass__ = type' '{}' '+')
|
||||
future1=$(find ./bin -type f -exec grep -HL 'from __future__ import (absolute_import, division, print_function)' '{}' '+')
|
||||
|
||||
# We eventually want to remove the module_utils and modules pruning from metaclass2 and future2
|
||||
# We eventually want to remove the module_utils pruning from metaclass2 and future2
|
||||
metaclass2=$(find ./lib/ansible -path ./lib/ansible/modules -prune \
|
||||
-o -path ./lib/ansible/module_utils -prune \
|
||||
-o -path ./lib/ansible/module_utils/six/_six.py -prune \
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
# We're getting rid of get_exception in our code so that we can deprecate it.
|
||||
# get_exception is no longer needed as we no longer support python-2.4 on the controller.
|
||||
|
||||
# We eventually want this list to be empty
|
||||
# We eventually want pycompat24 and basic.py to be the only things on this list
|
||||
get_exception=$(find . -path ./test/runner/.tox -prune \
|
||||
-o -path ./lib/ansible/module_utils -prune \
|
||||
-o -path ./lib/ansible/module_utils/pycompat24.py -prune \
|
||||
-o -path ./lib/ansible/module_utils/basic.py -prune \
|
||||
-o -path ./lib/ansible/modules/storage/netapp -prune \
|
||||
-o -path ./lib/ansible/modules/packaging/os -prune \
|
||||
-o -path ./lib/ansible/modules/monitoring -prune \
|
||||
|
@ -24,13 +25,21 @@ get_exception=$(find . -path ./test/runner/.tox -prune \
|
|||
-o -path ./lib/ansible/plugins/action/wait_for_connection.py -prune \
|
||||
-o -name '*.py' -type f -exec grep -H 'get_exception' '{}' '+')
|
||||
|
||||
basic_failed=0
|
||||
|
||||
if test -n "$get_exception" ; then
|
||||
printf "\n== Contains get_exception() calls ==\n"
|
||||
printf "%s" "$get_exception"
|
||||
failures=$(printf "%s" "$get_exception"| wc -l)
|
||||
failures=$((failures + 2))
|
||||
exit "$failures"
|
||||
if test "$(grep -c get_exception ./lib/ansible/module_utils/basic.py)" -gt 1 ; then
|
||||
printf "\n== basic.py contains get_exception calls ==\n\n"
|
||||
printf " basic.py is allowed to import get_exception for backwards compat but\n"
|
||||
printf " should not call it anywhere\n"
|
||||
basic_failed=1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
failures=0
|
||||
if test -n "$get_exception" ; then
|
||||
printf "\n== Contains get_exception() calls ==\n"
|
||||
printf " %s\n" "$get_exception"
|
||||
failures=$(printf "%s" "$get_exception"| wc -l)
|
||||
failures=$((failures + 2))
|
||||
fi
|
||||
|
||||
exit $((basic_failed + failures))
|
||||
|
|
|
@ -17,9 +17,6 @@ wildcard_imports=$(find . -path ./test/runner/.tox -prune \
|
|||
-o -path ./test/units/plugins/action/test_action.py \
|
||||
-o -path ./lib/ansible/compat/tests/mock.py -prune \
|
||||
-o -path ./lib/ansible/compat/tests/unittest.py \
|
||||
-o -path ./lib/ansible/module_utils/api.py -prune \
|
||||
-o -path ./lib/ansible/module_utils/cloud.py -prune \
|
||||
-o -path ./lib/ansible/module_utils/aos.py -prune \
|
||||
-o -path ./test/units/modules/network/cumulus/test_nclu.py -prune \
|
||||
-o -path ./lib/ansible/modules/cloud/amazon -prune \
|
||||
-o -path ./lib/ansible/modules/cloud/openstack -prune \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue