# How to make ansible-test work with mypy code

**URL:** <https://forum.ansible.com/t/how-to-make-ansible-test-work-with-mypy-code/38633>\
**Category:** Ansible Project\
**Created:** [December 19, 2023, 10:12pm UTC](https://forum.ansible.com/t/how-to-make-ansible-test-work-with-mypy-code/38633 "2023-12-19T22:12:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [December 19, 2023, 10:12pm UTC](https://forum.ansible.com/t/how-to-make-ansible-test-work-with-mypy-code/38633/1 "2023-12-19T22:12:19Z")

</div>

I’m using the latest ansible-test. Here is the code:

def cmd\_options\_params\_definition() → dict[str, Any]:  
…

here are the errors:

Running sanity test “import” on Python 3.6  
ERROR: plugins/module\_utils/ha\_cluster\_lsr/pcs\_api\_v2\_utils.py:93:0: traceback: TypeError: ‘type’ object is not subscriptable  
…  
Running sanity test “import” on Python 3.7  
ERROR: plugins/module\_utils/ha\_cluster\_lsr/pcs\_api\_v2\_utils.py:93:0: traceback: TypeError: ‘type’ object is not subscriptable  
…  
Running sanity test “import” on Python 3.8  
ERROR: plugins/module\_utils/ha\_cluster\_lsr/pcs\_api\_v2\_utils.py:93:0: traceback: TypeError: ‘type’ object is not subscriptable

I suppose I could create a tests/config.yml with

modules:  
python\_requires: “\>= 3.9”

but that seems like a pretty big hammer . . . hoping there is another way to handle this.
