Figured it out.
I am using parrot os which restricts the ansible version to 2.16 and has this bug:
github.com/ansible/ansible/issues/83755
To get around this I created a venv environment and installed ansible there. After doing that I no longer receive the above error.