From 10fe54de5844248c363f1acacd3b0746d8ccfd2e Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 20 Mar 2020 09:20:46 -0700 Subject: [PATCH] Fix ansible-test module_utils import analysis. Now empty `*.py` files are ignored during module_utils import analysis for change detection. This eliminates "No imports found" warnings for files which should have no imports. --- changelogs/fragments/ansible-test-change-detection-fix.yml | 2 ++ test/lib/ansible_test/_internal/import_analysis.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ansible-test-change-detection-fix.yml diff --git a/changelogs/fragments/ansible-test-change-detection-fix.yml b/changelogs/fragments/ansible-test-change-detection-fix.yml new file mode 100644 index 00000000000..3917afec3df --- /dev/null +++ b/changelogs/fragments/ansible-test-change-detection-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test now ignores empty ``*.py`` files when analyzing module_utils imports for change detection diff --git a/test/lib/ansible_test/_internal/import_analysis.py b/test/lib/ansible_test/_internal/import_analysis.py index d115cffa7f3..b718e04a60f 100644 --- a/test/lib/ansible_test/_internal/import_analysis.py +++ b/test/lib/ansible_test/_internal/import_analysis.py @@ -148,10 +148,10 @@ def enumerate_module_utils(): for path in data_context().content.walk_files(data_context().content.module_utils_path): ext = os.path.splitext(path)[1] - if path == os.path.join(data_context().content.module_utils_path, '__init__.py'): + if ext != '.py': continue - if ext != '.py': + if os.path.getsize(path) == 0: continue module_utils.append(get_python_module_utils_name(path))