Work on issues found by pylint (#896)

* Look at possibly-used-before-assignment.

* Use latest beta releases of ansible-core 2.19 for mypy and pylint.

* Look at unsupported-*.

* Look at unknown-option-value.

* Look at redefined-builtin.

* Look at superfluous-parens.

* Look at unspecified-encoding.

* Adjust to new cryptography version and to ansible-core 2.17's pylint.

* Look at super-with-arguments.

* Look at no-else-*.

* Look at try-except-raise.

* Look at inconsistent-return-statements.

* Look at redefined-outer-name.

* Look at redefined-argument-from-local.

* Look at attribute-defined-outside-init.

* Look at unused-variable.

* Look at protected-access.

* Look at raise-missing-from.

* Look at arguments-differ.

* Look at useless-suppression and use-symbolic-message-instead.

* Look at consider-using-dict-items.

* Look at consider-using-in.

* Look at consider-using-set-comprehension.

* Look at consider-using-with.

* Look at use-dict-literal.
This commit is contained in:
Felix Fontein
2025-05-18 00:57:28 +02:00
committed by GitHub
parent a3a5284f97
commit 318462fa24
96 changed files with 1748 additions and 1598 deletions

View File

@@ -786,11 +786,7 @@ class EcsCertificate:
self.set_cert_details(module)
assert self.cert_details is not None
if (
self.cert_status == "EXPIRED"
or self.cert_status == "SUSPENDED"
or self.cert_status == "REVOKED"
):
if self.cert_status in ("EXPIRED", "SUSPENDED", "REVOKED"):
return False
if self.cert_days < module.params["remaining_days"]:
return False
@@ -803,7 +799,7 @@ class EcsCertificate:
# Read the CSR contents
if self.csr and os.path.exists(self.csr):
with open(self.csr, "r") as csr_file:
with open(self.csr, "r", encoding="utf-8") as csr_file:
body["csr"] = csr_file.read()
# Check if the path is already a cert
@@ -849,6 +845,8 @@ class EcsCertificate:
result = self.ecs_client.ReissueCertRequest( # type: ignore[attr-defined] # pylint: disable=no-member
trackingId=self.tracking_id, Body=body
)
else:
raise AssertionError("Can never be reached") # pragma: no cover
self.tracking_id = result.get("trackingId")
self.set_cert_details(module)
assert self.cert_details is not None
@@ -914,61 +912,61 @@ class EcsCertificate:
def custom_fields_spec() -> dict[str, dict[str, str]]:
return dict(
text1=dict(type="str"),
text2=dict(type="str"),
text3=dict(type="str"),
text4=dict(type="str"),
text5=dict(type="str"),
text6=dict(type="str"),
text7=dict(type="str"),
text8=dict(type="str"),
text9=dict(type="str"),
text10=dict(type="str"),
text11=dict(type="str"),
text12=dict(type="str"),
text13=dict(type="str"),
text14=dict(type="str"),
text15=dict(type="str"),
number1=dict(type="float"),
number2=dict(type="float"),
number3=dict(type="float"),
number4=dict(type="float"),
number5=dict(type="float"),
date1=dict(type="str"),
date2=dict(type="str"),
date3=dict(type="str"),
date4=dict(type="str"),
date5=dict(type="str"),
email1=dict(type="str"),
email2=dict(type="str"),
email3=dict(type="str"),
email4=dict(type="str"),
email5=dict(type="str"),
dropdown1=dict(type="str"),
dropdown2=dict(type="str"),
dropdown3=dict(type="str"),
dropdown4=dict(type="str"),
dropdown5=dict(type="str"),
)
return {
"text1": {"type": "str"},
"text2": {"type": "str"},
"text3": {"type": "str"},
"text4": {"type": "str"},
"text5": {"type": "str"},
"text6": {"type": "str"},
"text7": {"type": "str"},
"text8": {"type": "str"},
"text9": {"type": "str"},
"text10": {"type": "str"},
"text11": {"type": "str"},
"text12": {"type": "str"},
"text13": {"type": "str"},
"text14": {"type": "str"},
"text15": {"type": "str"},
"number1": {"type": "float"},
"number2": {"type": "float"},
"number3": {"type": "float"},
"number4": {"type": "float"},
"number5": {"type": "float"},
"date1": {"type": "str"},
"date2": {"type": "str"},
"date3": {"type": "str"},
"date4": {"type": "str"},
"date5": {"type": "str"},
"email1": {"type": "str"},
"email2": {"type": "str"},
"email3": {"type": "str"},
"email4": {"type": "str"},
"email5": {"type": "str"},
"dropdown1": {"type": "str"},
"dropdown2": {"type": "str"},
"dropdown3": {"type": "str"},
"dropdown4": {"type": "str"},
"dropdown5": {"type": "str"},
}
def ecs_certificate_argument_spec() -> dict[str, dict[str, t.Any]]:
return dict(
backup=dict(type="bool", default=False),
force=dict(type="bool", default=False),
path=dict(type="path", required=True),
full_chain_path=dict(type="path"),
tracking_id=dict(type="int"),
remaining_days=dict(type="int", default=30),
request_type=dict(
type="str",
default="new",
choices=["new", "renew", "reissue", "validate_only"],
),
cert_type=dict(
type="str",
choices=[
return {
"backup": {"type": "bool", "default": False},
"force": {"type": "bool", "default": False},
"path": {"type": "path", "required": True},
"full_chain_path": {"type": "path"},
"tracking_id": {"type": "int"},
"remaining_days": {"type": "int", "default": 30},
"request_type": {
"type": "str",
"default": "new",
"choices": ["new", "renew", "reissue", "validate_only"],
},
"cert_type": {
"type": "str",
"choices": [
"STANDARD_SSL",
"ADVANTAGE_SSL",
"UC_SSL",
@@ -984,26 +982,27 @@ def ecs_certificate_argument_spec() -> dict[str, dict[str, t.Any]]:
"CDS_ENT_PRO",
"SMIME_ENT",
],
),
csr=dict(type="str"),
subject_alt_name=dict(type="list", elements="str"),
eku=dict(
type="str", choices=["SERVER_AUTH", "CLIENT_AUTH", "SERVER_AND_CLIENT_AUTH"]
),
ct_log=dict(type="bool"),
client_id=dict(type="int", default=1),
org=dict(type="str"),
ou=dict(type="list", elements="str"),
end_user_key_storage_agreement=dict(type="bool"),
tracking_info=dict(type="str"),
requester_name=dict(type="str", required=True),
requester_email=dict(type="str", required=True),
requester_phone=dict(type="str", required=True),
additional_emails=dict(type="list", elements="str"),
custom_fields=dict(type="dict", default=None, options=custom_fields_spec()),
cert_expiry=dict(type="str"),
cert_lifetime=dict(type="str", choices=["P1Y", "P2Y", "P3Y"]),
)
},
"csr": {"type": "str"},
"subject_alt_name": {"type": "list", "elements": "str"},
"eku": {
"type": "str",
"choices": ["SERVER_AUTH", "CLIENT_AUTH", "SERVER_AND_CLIENT_AUTH"],
},
"ct_log": {"type": "bool"},
"client_id": {"type": "int", "default": 1},
"org": {"type": "str"},
"ou": {"type": "list", "elements": "str"},
"end_user_key_storage_agreement": {"type": "bool"},
"tracking_info": {"type": "str"},
"requester_name": {"type": "str", "required": True},
"requester_email": {"type": "str", "required": True},
"requester_phone": {"type": "str", "required": True},
"additional_emails": {"type": "list", "elements": "str"},
"custom_fields": {"type": "dict", "options": custom_fields_spec()},
"cert_expiry": {"type": "str"},
"cert_lifetime": {"type": "str", "choices": ["P1Y", "P2Y", "P3Y"]},
}
def main() -> t.NoReturn: