Skip to content

Commit

Permalink
Admin: Fix MyPy 1.11.0 compatibility (#7876)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Jul 21, 2024
1 parent ba76bca commit 9c32aa8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions moto/acmpca/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def __init__(
self.usage_mode = "SHORT_LIVED_CERTIFICATE"
self.security_standard = security_standard or "FIPS_140_2_LEVEL_3_OR_HIGHER"

common_name = self.certificate_authority_configuration.get("Subject", {}).get(
"CommonName", "Moto.org"
)
self.common_name = self.certificate_authority_configuration.get(
"Subject", {}
).get("CommonName", "Moto.org")
self.key = cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key(
public_exponent=65537, key_size=2048
)
Expand All @@ -60,7 +60,7 @@ def __init__(
)
self.certificate: Optional[Certificate] = None
self.certificate_chain: Optional[bytes] = None
self.csr = self.generate_csr(common_name)
self.csr = self.generate_csr(self.common_name)

self.issued_certificates: Dict[str, bytes] = dict()

Expand Down Expand Up @@ -116,7 +116,9 @@ def generate_csr(self, common_name: str) -> bytes:

def issue_certificate(self, csr_bytes: bytes) -> str:
cert = cryptography.x509.load_pem_x509_csr(base64.b64decode(csr_bytes))
new_cert = self.generate_cert(common_name="", subject=cert.subject)
new_cert = self.generate_cert(
common_name=self.common_name, subject=cert.subject
)
cert_id = str(mock_random.uuid4()).replace("-", "")
cert_arn = f"arn:{get_partition(self.region_name)}:acm-pca:{self.region_name}:{self.account_id}:certificate-authority/{self.id}/certificate/{cert_id}"
self.issued_certificates[cert_arn] = new_cert
Expand Down
6 changes: 3 additions & 3 deletions moto/awslambda/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import namedtuple
from functools import partial
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any, Type, Union

from moto.utilities.utils import PARTITION_NAMES, get_partition

Expand All @@ -22,7 +22,7 @@ def make_arn(resource_type: str, region: str, account: str, name: str) -> str:


def make_ver_arn(
resource_type: str, region: str, account: str, name: str, version: str = "1"
resource_type: str, region: str, account: str, name: str, version: Any = "1"
) -> str:
arn = make_arn(resource_type, region, account, name)
return f"{arn}:{version}"
Expand All @@ -32,7 +32,7 @@ def make_ver_arn(
make_layer_ver_arn = partial(make_ver_arn, "layer")


def split_arn(arn_type: Callable[[str, str, str, str], str], arn: str) -> Any:
def split_arn(arn_type: Union[Type[ARN], Type[LAYER_ARN]], arn: str) -> Any:
for partition in PARTITION_NAMES:
arn = arn.replace(f"arn:{partition}:lambda:", "")

Expand Down
2 changes: 1 addition & 1 deletion moto/cloudformation/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def load_conditions(self) -> None:
self.lazy_condition_map[condition_name] = functools.partial(
parse_condition,
condition,
self._parsed_resources,
self._parsed_resources, # type: ignore
self.lazy_condition_map,
)

Expand Down
2 changes: 1 addition & 1 deletion moto/moto_proxy/proxy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def do_GET(self) -> None:
boundary = self.headers["Content-Type"].split("boundary=")[-1]
req_body, form_data = get_body_from_form_data(req_body, boundary) # type: ignore
for key, val in form_data.items():
self.headers[key] = [val]
self.headers[key] = [val] # type: ignore
else:
form_data = {}

Expand Down

0 comments on commit 9c32aa8

Please sign in to comment.