Skip to content

Commit e4cddec

Browse files
authored
Merge branch 'master' into prep/5.2.0
2 parents 12574ab + f92709e commit e4cddec

588 files changed

Lines changed: 71084 additions & 49361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
git tag ${{ env.VERSION }}
7474
git push origin ${{ env.VERSION }}
7575
- name: Create GitHub release
76-
uses: softprops/action-gh-release@v2
76+
uses: softprops/action-gh-release@v3
7777
with:
7878
name: ${{ env.VERSION }}
7979
tag_name: ${{ env.VERSION }}

.github/workflows/tests_sdk_ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v6
1515
- name: Set up Ruby ${{ matrix.ruby-version }}
16-
uses: ruby/setup-ruby@3ff19f5e2baf30647122352b96108b1fbe250c64
16+
uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f
1717
with:
1818
ruby-version: ${{ matrix.ruby-version }}
1919
- name: Set up Python

moto/acm/models.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import ipaddress
55
import re
66
from collections.abc import Iterable
7-
from typing import Any, Optional
7+
from typing import Any
88

99
import cryptography.hazmat.primitives.asymmetric.rsa
1010
import cryptography.x509
@@ -64,12 +64,12 @@ def datetime_to_epoch(date: datetime.datetime) -> float:
6464
return float(calendar.timegm(aware_dt.timetuple()))
6565

6666

67-
class TagHolder(dict[str, Optional[str]]):
67+
class TagHolder(dict[str, str | None]):
6868
MAX_TAG_COUNT = 50
6969
MAX_KEY_LENGTH = 128
7070
MAX_VALUE_LENGTH = 256
7171

72-
def _validate_kv(self, key: str, value: Optional[str], index: int) -> None:
72+
def _validate_kv(self, key: str, value: str | None, index: int) -> None:
7373
if len(key) > self.MAX_KEY_LENGTH:
7474
raise AWSValidationException(
7575
f"Value '{key}' at 'tags.{index}.member.key' failed to satisfy constraint: Member must have length less than or equal to {self.MAX_KEY_LENGTH}"
@@ -127,13 +127,13 @@ def __init__(
127127
account_id: str,
128128
certificate: bytes,
129129
private_key: bytes,
130-
chain: Optional[bytes] = None,
130+
chain: bytes | None = None,
131131
region: str = "us-east-1",
132-
arn: Optional[str] = None,
132+
arn: str | None = None,
133133
cert_type: str = "IMPORTED",
134134
cert_status: str = "ISSUED",
135-
cert_authority_arn: Optional[str] = None,
136-
cert_options: Optional[dict[str, Any]] = None,
135+
cert_authority_arn: str | None = None,
136+
cert_options: dict[str, Any] | None = None,
137137
):
138138
self.created_at = utcnow()
139139
self.cert = certificate
@@ -175,8 +175,8 @@ def generate_cert(
175175
domain_name: str,
176176
account_id: str,
177177
region: str,
178-
sans: Optional[list[str]] = None,
179-
cert_authority_arn: Optional[str] = None,
178+
sans: list[str] | None = None,
179+
cert_authority_arn: str | None = None,
180180
) -> "CertBundle":
181181
unique_sans: set[str] = set(sans) if sans else set()
182182

@@ -477,7 +477,7 @@ def set_certificate_in_use_by(self, arn: str, load_balancer_name: str) -> None:
477477
cert_bundle = self._certificates[arn]
478478
cert_bundle.in_use_by.append(load_balancer_name)
479479

480-
def _get_arn_from_idempotency_token(self, token: str) -> Optional[str]:
480+
def _get_arn_from_idempotency_token(self, token: str) -> str | None:
481481
"""
482482
If token doesnt exist, return None, later it will be
483483
set with an expiry and arn.
@@ -510,8 +510,8 @@ def import_certificate(
510510
self,
511511
certificate: bytes,
512512
private_key: bytes,
513-
chain: Optional[bytes],
514-
arn: Optional[str],
513+
chain: bytes | None,
514+
arn: str | None,
515515
tags: list[dict[str, str]],
516516
) -> str:
517517
if arn is not None:
@@ -594,8 +594,8 @@ def request_certificate(
594594
idempotency_token: str,
595595
subject_alt_names: list[str],
596596
tags: list[dict[str, str]],
597-
cert_authority_arn: Optional[str] = None,
598-
cert_options: Optional[dict[str, Any]] = None,
597+
cert_authority_arn: str | None = None,
598+
cert_options: dict[str, Any] | None = None,
599599
) -> str:
600600
"""
601601
The parameter DomainValidationOptions has not yet been implemented

moto/acm/responses.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import base64
22
import json
3-
from typing import Union
43

54
from moto.core.responses import BaseResponse
65

76
from .exceptions import AWSValidationException
87
from .models import AWSCertificateManagerBackend, acm_backends
98

10-
GENERIC_RESPONSE_TYPE = Union[str, tuple[str, dict[str, int]]]
9+
GENERIC_RESPONSE_TYPE = str | tuple[str, dict[str, int]]
1110

1211

1312
class AWSCertificateManagerResponse(BaseResponse):

moto/acmpca/models.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import base64
44
import contextlib
55
import datetime
6-
from typing import Any, Optional, cast
6+
from typing import Any, cast
77

88
from cryptography import x509
99
from cryptography.hazmat.backends import default_backend
@@ -35,7 +35,7 @@ def __init__(
3535
certificate_authority_configuration: dict[str, Any],
3636
certificate_authority_type: str,
3737
revocation_configuration: dict[str, Any],
38-
security_standard: Optional[str],
38+
security_standard: str | None,
3939
):
4040
self.id = mock_random.uuid4()
4141
self.arn = f"arn:{get_partition(region)}:acm-pca:{region}:{account_id}:certificate-authority/{self.id}"
@@ -48,11 +48,11 @@ def __init__(
4848
}
4949
self.set_revocation_configuration(revocation_configuration)
5050
self.created_at = unix_time()
51-
self.updated_at: Optional[float] = None
51+
self.updated_at: float | None = None
5252
self.status = "PENDING_CERTIFICATE"
5353
self.usage_mode = "SHORT_LIVED_CERTIFICATE"
5454
self.security_standard = security_standard or "FIPS_140_2_LEVEL_3_OR_HIGHER"
55-
self.policy: Optional[str] = None
55+
self.policy: str | None = None
5656
self.revoked_certificates: dict[str, dict[str, Any]] = {}
5757

5858
self.password = str(mock_random.uuid4()).encode("utf-8")
@@ -65,7 +65,7 @@ def __init__(
6565
)
6666

6767
self.certificate_bytes: bytes = b""
68-
self.certificate_chain: Optional[bytes] = None
68+
self.certificate_chain: bytes | None = None
6969
self.issued_certificates: dict[str, bytes] = {}
7070
self.issued_certificates_certificate_chains: dict[str, bytes] = {}
7171

@@ -103,7 +103,7 @@ def key(self) -> rsa.RSAPrivateKey:
103103
return cast(rsa.RSAPrivateKey, private_key)
104104

105105
@property
106-
def certificate(self) -> Optional[x509.Certificate]:
106+
def certificate(self) -> x509.Certificate | None:
107107
if self.certificate_bytes:
108108
return x509.load_pem_x509_certificate(self.certificate_bytes)
109109
return None
@@ -153,7 +153,7 @@ def csr(self) -> bytes:
153153
)
154154
return csr.public_bytes(serialization.Encoding.PEM)
155155

156-
def issue_certificate(self, csr_bytes: bytes, template_arn: Optional[str]) -> str:
156+
def issue_certificate(self, csr_bytes: bytes, template_arn: str | None) -> str:
157157
csr = x509.load_pem_x509_csr(base64.b64decode(csr_bytes))
158158
extensions = self._x509_extensions(csr, template_arn)
159159
new_cert = self.generate_cert(
@@ -177,7 +177,7 @@ def issue_certificate(self, csr_bytes: bytes, template_arn: Optional[str]) -> st
177177
return cert_arn
178178

179179
def _x509_extensions(
180-
self, csr: x509.CertificateSigningRequest, template_arn: Optional[str]
180+
self, csr: x509.CertificateSigningRequest, template_arn: str | None
181181
) -> list[tuple[x509.ExtensionType, bool]]:
182182
"""
183183
Uses a PCA certificate template ARN to return a list of X.509 extensions.
@@ -283,7 +283,7 @@ def get_certificate(self, certificate_arn: str) -> tuple[bytes, bytes]:
283283
return certificate, certificate_chain
284284

285285
def set_revocation_configuration(
286-
self, revocation_configuration: Optional[dict[str, Any]]
286+
self, revocation_configuration: dict[str, Any] | None
287287
) -> None:
288288
if revocation_configuration is not None:
289289
self.revocation_configuration = revocation_configuration
@@ -300,7 +300,7 @@ def set_revocation_configuration(
300300
raise InvalidS3ObjectAclInCrlConfiguration(acl)
301301

302302
@property
303-
def not_valid_after(self) -> Optional[float]:
303+
def not_valid_after(self) -> float | None:
304304
if self.certificate is None:
305305
return None
306306
try:
@@ -309,7 +309,7 @@ def not_valid_after(self) -> Optional[float]:
309309
return unix_time(self.certificate.not_valid_after)
310310

311311
@property
312-
def not_valid_before(self) -> Optional[float]:
312+
def not_valid_before(self) -> float | None:
313313
if self.certificate is None:
314314
return None
315315
try:
@@ -318,7 +318,7 @@ def not_valid_before(self) -> Optional[float]:
318318
return unix_time(self.certificate.not_valid_before)
319319

320320
def import_certificate_authority_certificate(
321-
self, certificate: bytes, certificate_chain: Optional[bytes]
321+
self, certificate: bytes, certificate_chain: bytes | None
322322
) -> None:
323323
try:
324324
x509.load_pem_x509_certificate(certificate)
@@ -376,7 +376,7 @@ def create_certificate_authority(
376376
certificate_authority_configuration: dict[str, Any],
377377
revocation_configuration: dict[str, Any],
378378
certificate_authority_type: str,
379-
security_standard: Optional[str],
379+
security_standard: str | None,
380380
tags: list[dict[str, str]],
381381
) -> str:
382382
"""
@@ -404,7 +404,7 @@ def describe_certificate_authority(
404404

405405
def get_certificate_authority_certificate(
406406
self, certificate_authority_arn: str
407-
) -> tuple[bytes, Optional[bytes]]:
407+
) -> tuple[bytes, bytes | None]:
408408
ca = self.describe_certificate_authority(certificate_authority_arn)
409409
if ca.status != "ACTIVE":
410410
raise InvalidStateException(certificate_authority_arn)
@@ -439,7 +439,7 @@ def delete_certificate_authority(self, certificate_authority_arn: str) -> None:
439439
ca.status = "DELETED"
440440

441441
def issue_certificate(
442-
self, certificate_authority_arn: str, csr: bytes, template_arn: Optional[str]
442+
self, certificate_authority_arn: str, csr: bytes, template_arn: str | None
443443
) -> str:
444444
"""
445445
The following parameters are not yet implemented: ApiPassthrough, SigningAlgorithm, Validity, ValidityNotBefore, IdempotencyToken
@@ -471,7 +471,7 @@ def import_certificate_authority_certificate(
471471
self,
472472
certificate_authority_arn: str,
473473
certificate: bytes,
474-
certificate_chain: Optional[bytes],
474+
certificate_chain: bytes | None,
475475
) -> None:
476476
ca = self.describe_certificate_authority(certificate_authority_arn)
477477
ca.import_certificate_authority_certificate(certificate, certificate_chain)
@@ -532,7 +532,7 @@ def delete_policy(self, resource_arn: str) -> None:
532532
@paginate(pagination_model=PAGINATION_MODEL)
533533
def list_certificate_authorities(
534534
self,
535-
resource_owner: Optional[str] = None,
535+
resource_owner: str | None = None,
536536
) -> list[CertificateAuthority]:
537537
"""
538538
Lists the private certificate authorities that you created by using the CreateCertificateAuthority action.

moto/amp/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""PrometheusServiceBackend class with methods for supported APIs."""
22

33
from collections.abc import Callable
4-
from typing import Any, Optional
4+
from typing import Any
55

66
from moto.core.base_backend import BackendDict, BaseBackend
77
from moto.core.common_models import BaseModel
@@ -64,7 +64,7 @@ def __init__(
6464
self.created_at = unix_time()
6565
self.tag_fn = tag_fn
6666
self.rule_group_namespaces: dict[str, RuleGroupNamespace] = {}
67-
self.logging_config: Optional[dict[str, Any]] = None
67+
self.logging_config: dict[str, Any] | None = None
6868

6969
def to_dict(self) -> dict[str, Any]:
7070
return {

moto/apigateway/integration_parsers/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import abc
2-
from typing import Union
32

43
from requests.models import PreparedRequest
54

@@ -10,5 +9,5 @@ class IntegrationParser:
109
@abc.abstractmethod
1110
def invoke(
1211
self, request: PreparedRequest, integration: Integration
13-
) -> tuple[int, Union[str, bytes]]:
12+
) -> tuple[int, str | bytes]:
1413
pass

moto/apigateway/integration_parsers/aws_parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Union
2-
31
import requests
42

53
from ..models import Integration
@@ -9,7 +7,7 @@
97
class TypeAwsParser(IntegrationParser):
108
def invoke(
119
self, request: requests.PreparedRequest, integration: Integration
12-
) -> tuple[int, Union[str, bytes]]:
10+
) -> tuple[int, str | bytes]:
1311
# integration.uri = arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}
1412
# example value = 'arn:aws:apigateway:us-west-2:dynamodb:action/PutItem'
1513
try:

moto/apigateway/integration_parsers/http_parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Union
2-
31
import requests
42

53
from ..models import Integration
@@ -13,7 +11,7 @@ class TypeHttpParser(IntegrationParser):
1311

1412
def invoke(
1513
self, request: requests.PreparedRequest, integration: Integration
16-
) -> tuple[int, Union[str, bytes]]:
14+
) -> tuple[int, str | bytes]:
1715
uri = integration.uri
1816
requests_func = getattr(requests, integration.http_method.lower()) # type: ignore[union-attr]
1917
response = requests_func(uri)

moto/apigateway/integration_parsers/unknown_parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Union
2-
31
import requests
42

53
from ..models import Integration
@@ -13,6 +11,6 @@ class TypeUnknownParser(IntegrationParser):
1311

1412
def invoke(
1513
self, request: requests.PreparedRequest, integration: Integration
16-
) -> tuple[int, Union[str, bytes]]:
14+
) -> tuple[int, str | bytes]:
1715
_type = integration.integration_type
1816
raise NotImplementedError(f"The {_type} type has not been implemented")

0 commit comments

Comments
 (0)