Repository: ansible-collections/community.general

Issue:
The DependencyMixin is being deprecated.
### Summary

When I use the module to blacklist a kernel module, a warning appears.

### Issue Type

Bug Report

### Component Name

kernel_blacklist

### Ansible Version

```console (paste below)
$ansible --version
ansible [core 2.15.0]
  config file = None
  configured module search path = ['/home/bandura/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/bandura/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/bandura/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/bandura/.local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
```


### Community.general Version

```console (paste below)
$ansible-galaxy collection list community.general

# /home/bandura/.local/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 7.0.1
```


### Configuration

```console (paste below)
$ansible-config dump --only-changed
CONFIG_FILE() = None
```


### OS / Environment

Debian 11-based

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
- name: Blacklist old kernel module
  become: true
  community.general.kernel_blacklist:
    name: x_tables
```


### Expected Results

No warning

### Actual Results

Works, but with warning.
```console (paste below)
TASK [install-nftables : Blacklist old IPv4 kernel module] *********************
[DEPRECATION WARNING]: The DependencyMixin is being deprecated. Modules should 
use community.general.plugins.module_utils.deps instead. This feature will be 
removed from community.general in version 9.0.0. Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg.
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
CC @russoz
cc @matze
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
The deprecation was added in #6465. @russoz do you think you can adjust the code to only emit it if it is used explicitly outside of ModuleHelper? Otherwise we should probably revert the deprecation for now.
hi, that mixin is not going to work outside of ModuleHelper (unless someone create a class that mimics some aspects of MH).

But I found out what seems to be the problem: that deprecation is popping up regardless if the dependency mixin is actually used - in fact `kernel_blacklist` does not use it. I will be submitting a PR tomorrow to address that.

Resolving patch:
diff --git a/plugins/module_utils/mh/mixins/deps.py b/plugins/module_utils/mh/mixins/deps.py
--- a/plugins/module_utils/mh/mixins/deps.py
+++ b/plugins/module_utils/mh/mixins/deps.py
@@ -52,6 +52,8 @@ def dependency(cls, name, msg):
         return cls._dependencies[-1]
 
     def fail_on_missing_deps(self):
+        if not self._dependencies:
+            return
         self.module.deprecate(
             'The DependencyMixin is being deprecated. '
             'Modules should use community.general.plugins.module_utils.deps instead.',


Test patch:
diff --git a/tests/integration/targets/kernel_blacklist/tasks/main.yml b/tests/integration/targets/kernel_blacklist/tasks/main.yml
--- a/tests/integration/targets/kernel_blacklist/tasks/main.yml
+++ b/tests/integration/targets/kernel_blacklist/tasks/main.yml
@@ -36,6 +36,13 @@
     path: '{{ bl_file }}'
   register: stat_test_1
 
+- name: show bl_test_1
+  ansible.builtin.debug:
+    var: bl_test_1_depr_msgs
+  vars:
+    bl_test_1_depr_msgs: "{{ (bl_test_1.deprecations | default([])) | map(attribute='msg') }}"
+    # q('ansible.builtin.subelements', bl_test_1, 'deprecations', {'skip_missing': True}) }}"
+
 - name: assert file is unchanged
   assert:
     that:
@@ -49,12 +56,17 @@
     expected_content: |
       # Copyright (c) Ansible Project
       # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
-      # SPDX-{{ '' }}License-Identifier: GPL-3.0-or-later
+      # SPDX{{ '' }}-License-Identifier: GPL-3.0-or-later
 
       blacklist aaaa
       blacklist bbbb
       blacklist cccc
 
+- name: test deprecation
+  assert:
+    that:
+    - "'deprecations' not in bl_test_1 or (ansible_version.major == 2 and ansible_version.minor == 12)"
+
 - name: add new item to list
   community.general.kernel_blacklist:
     blacklist_file: '{{ bl_file }}'
@@ -76,7 +88,7 @@
     content: |
       # Copyright (c) Ansible Project
       # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
-      # SPDX-{{ '' }}License-Identifier: GPL-3.0-or-later
+      # SPDX{{ '' }}-License-Identifier: GPL-3.0-or-later
 
       blacklist aaaa
       blacklist bbbb
@@ -104,7 +116,7 @@
     content: |
       # Copyright (c) Ansible Project
       # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
-      # SPDX-{{ '' }}License-Identifier: GPL-3.0-or-later
+      # SPDX{{ '' }}-License-Identifier: GPL-3.0-or-later
 
       blacklist aaaa
       blacklist cccc