From ad71c6766161be634e7fa8316b15246b004f8481 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Wed, 25 Sep 2024 04:12:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Temporarily=20suppress=20MyPy=20?= =?UTF-8?q?violations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FIXME: address each ignored violation gradually --- .github/workflows/ci-cd.yml | 25 +--------------- src/awx_plugins/credentials/aim.py | 3 ++ .../credentials/aws_secretsmanager.py | 3 ++ src/awx_plugins/credentials/azure_kv.py | 3 ++ src/awx_plugins/credentials/centrify_vault.py | 3 ++ src/awx_plugins/credentials/conjur.py | 3 ++ src/awx_plugins/credentials/dsv.py | 3 ++ src/awx_plugins/credentials/hashivault.py | 29 ++++++++++++++----- src/awx_plugins/credentials/injectors.py | 3 ++ src/awx_plugins/credentials/plugin.py | 3 ++ src/awx_plugins/credentials/plugins.py | 3 ++ src/awx_plugins/credentials/tss.py | 3 ++ src/awx_plugins/inventory/plugins.py | 3 ++ tests/credential_plugins_test.py | 3 ++ 14 files changed, 58 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 6919411870..52c0f699db 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -606,36 +606,13 @@ jobs: - linkcheck-docs - spellcheck-docs environment-variables: - - >- # only affects pre-commit, set for all for simplicity: - SKIP=mypy + - '' tox-run-posargs: - '' xfail: - false check-name: - '' - include: - - runner-vm-os: ubuntu-latest - python-version: 3.11 - toxenv: pre-commit - environment-variables: '' - tox-run-posargs: mypy-py313 --all-files - xfail: true - check-name: MyPy @ Python 3.13 - - runner-vm-os: ubuntu-latest - python-version: 3.11 - toxenv: pre-commit - environment-variables: '' - tox-run-posargs: mypy-py312 --all-files - xfail: true - check-name: MyPy @ Python 3.12 - - runner-vm-os: ubuntu-latest - python-version: 3.11 - toxenv: pre-commit - environment-variables: '' - tox-run-posargs: mypy-py311 --all-files - xfail: true - check-name: MyPy @ Python 3.11 fail-fast: false uses: ./.github/workflows/reusable-tox.yml with: diff --git a/src/awx_plugins/credentials/aim.py b/src/awx_plugins/credentials/aim.py index ce5b2d2f8d..e90bd11007 100644 --- a/src/awx_plugins/credentials/aim.py +++ b/src/awx_plugins/credentials/aim.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="no-untyped-call, no-untyped-def" + from urllib.parse import quote, urlencode, urljoin import requests diff --git a/src/awx_plugins/credentials/aws_secretsmanager.py b/src/awx_plugins/credentials/aws_secretsmanager.py index 3ce0aeeb5a..561e1ee46d 100644 --- a/src/awx_plugins/credentials/aws_secretsmanager.py +++ b/src/awx_plugins/credentials/aws_secretsmanager.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="no-untyped-def" + import boto3 from botocore.exceptions import ClientError diff --git a/src/awx_plugins/credentials/azure_kv.py b/src/awx_plugins/credentials/azure_kv.py index 1e7893058d..1f46ea6493 100644 --- a/src/awx_plugins/credentials/azure_kv.py +++ b/src/awx_plugins/credentials/azure_kv.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="import-untyped, no-untyped-def" + from azure.identity import ClientSecretCredential from azure.keyvault.secrets import SecretClient from msrestazure import azure_cloud diff --git a/src/awx_plugins/credentials/centrify_vault.py b/src/awx_plugins/credentials/centrify_vault.py index c7d77250c1..f715895bdc 100644 --- a/src/awx_plugins/credentials/centrify_vault.py +++ b/src/awx_plugins/credentials/centrify_vault.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="no-untyped-call, no-untyped-def, type-var" + from urllib.parse import urljoin import requests diff --git a/src/awx_plugins/credentials/conjur.py b/src/awx_plugins/credentials/conjur.py index f83ad33362..74ff0cd1d7 100644 --- a/src/awx_plugins/credentials/conjur.py +++ b/src/awx_plugins/credentials/conjur.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="arg-type, no-untyped-call, no-untyped-def" + import base64 import binascii from urllib.parse import quote, urljoin diff --git a/src/awx_plugins/credentials/dsv.py b/src/awx_plugins/credentials/dsv.py index e74a25608b..d9ad2e3046 100644 --- a/src/awx_plugins/credentials/dsv.py +++ b/src/awx_plugins/credentials/dsv.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="attr-defined, import-untyped, no-untyped-def" + from base64 import b64decode from delinea.secrets.vault import PasswordGrantAuthorizer, SecretsVault diff --git a/src/awx_plugins/credentials/hashivault.py b/src/awx_plugins/credentials/hashivault.py index c587189d12..d090994bc3 100644 --- a/src/awx_plugins/credentials/hashivault.py +++ b/src/awx_plugins/credentials/hashivault.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="arg-type, no-untyped-call, no-untyped-def" + import copy import os import pathlib @@ -175,7 +178,7 @@ } hashi_kv_inputs = copy.deepcopy(base_inputs) -hashi_kv_inputs['fields'].append( +hashi_kv_inputs['fields'].append( # type: ignore[attr-defined] # FIXME { 'id': 'api_version', 'label': _('API Version'), @@ -188,7 +191,7 @@ }, ) hashi_kv_inputs['metadata'] = ( - [ + [ # type: ignore[operator] # FIXME { 'id': 'secret_backend', 'label': _('Name of Secret Backend'), @@ -218,11 +221,13 @@ }, ] ) -hashi_kv_inputs['required'].extend(['api_version', 'secret_key']) +hashi_kv_inputs['required'].extend( # type: ignore[attr-defined] # FIXME + ['api_version', 'secret_key'], +) hashi_ssh_inputs = copy.deepcopy(base_inputs) hashi_ssh_inputs['metadata'] = ( - [ + [ # type: ignore[operator] # FIXME { 'id': 'public_key', 'label': _('Unsigned Public Key'), @@ -249,7 +254,9 @@ }, ] ) -hashi_ssh_inputs['required'].extend(['public_key', 'role']) +hashi_ssh_inputs['required'].extend( # type: ignore[attr-defined] # FIXME + ['public_key', 'role'], +) def handle_auth(**kwargs): @@ -356,7 +363,9 @@ def kv_backend(**kwargs): if api_version == 'v2': if kwargs.get('secret_version'): - request_kwargs['params'] = {'version': kwargs['secret_version']} + request_kwargs['params'] = { # type: ignore[assignment] # FIXME + 'version': kwargs['secret_version'], + } if secret_backend: path_segments = [secret_backend, 'data', secret_path] else: @@ -416,9 +425,13 @@ def ssh_backend(**kwargs): 'allow_redirects': False, } - request_kwargs['json'] = {'public_key': kwargs['public_key']} + request_kwargs['json'] = { # type: ignore[assignment] # FIXME + 'public_key': kwargs['public_key'], + } if kwargs.get('valid_principals'): - request_kwargs['json']['valid_principals'] = kwargs['valid_principals'] + request_kwargs['json'][ + 'valid_principals' + ] = kwargs['valid_principals'] # type: ignore[index] # FIXME sess = requests.Session() sess.mount(url, requests.adapters.HTTPAdapter(max_retries=5)) diff --git a/src/awx_plugins/credentials/injectors.py b/src/awx_plugins/credentials/injectors.py index 04c744b4e0..0acb098d0f 100644 --- a/src/awx_plugins/credentials/injectors.py +++ b/src/awx_plugins/credentials/injectors.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="no-untyped-call, no-untyped-def" + import json import os import stat diff --git a/src/awx_plugins/credentials/plugin.py b/src/awx_plugins/credentials/plugin.py index adc4ef5c02..bd200a3102 100644 --- a/src/awx_plugins/credentials/plugin.py +++ b/src/awx_plugins/credentials/plugin.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="assignment, no-untyped-def" + import os import tempfile from collections import namedtuple diff --git a/src/awx_plugins/credentials/plugins.py b/src/awx_plugins/credentials/plugins.py index 778592744c..2eeb40a037 100644 --- a/src/awx_plugins/credentials/plugins.py +++ b/src/awx_plugins/credentials/plugins.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="assignment, misc, no-redef" + from __future__ import annotations diff --git a/src/awx_plugins/credentials/tss.py b/src/awx_plugins/credentials/tss.py index fced61450c..09394de4d7 100644 --- a/src/awx_plugins/credentials/tss.py +++ b/src/awx_plugins/credentials/tss.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="no-untyped-def, import-not-found, import-untyped" + from .plugin import CredentialPlugin, translate_function as _ diff --git a/src/awx_plugins/inventory/plugins.py b/src/awx_plugins/inventory/plugins.py index cd6c881c81..db9cc0e805 100644 --- a/src/awx_plugins/inventory/plugins.py +++ b/src/awx_plugins/inventory/plugins.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="assignment, no-untyped-call, no-untyped-def, var-annotated" + import os.path import stat import tempfile diff --git a/tests/credential_plugins_test.py b/tests/credential_plugins_test.py index acb48bb121..2c2f3eae67 100644 --- a/tests/credential_plugins_test.py +++ b/tests/credential_plugins_test.py @@ -1,3 +1,6 @@ +# FIXME: the following violations must be addressed gradually and unignored +# mypy: disable-error-code="no-untyped-call" + from unittest import mock import pytest