Skip to content

Commit 3ba58cb

Browse files
committed
Add better pricing typings
Pricing functions can be better typed with types-boto3
1 parent 26dfbd8 commit 3ba58cb

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ check = [
5050
"types-requests",
5151
"types-setuptools",
5252
"python-on-whales",
53-
"types-boto3[essential,cloudfront,ec2,ecr,iam,lambda,secretsmanager,sts]",
53+
"types-boto3[essential,cloudfront,ec2,ecr,iam,lambda,pricing,secretsmanager,sts]",
5454
]
5555

5656
[tool.setuptools.dynamic]

src/e3/aws/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from types_boto3_ecr import ECRClient
4040
from types_boto3_iam import IAMClient
4141
from types_boto3_lambda import LambdaClient
42+
from types_boto3_pricing import PricingClient
4243
from types_boto3_s3 import S3Client
4344
from types_boto3_secretsmanager import SecretsManagerClient
4445
from types_boto3_sts import STSClient
@@ -321,6 +322,11 @@ def client(
321322
self, name: Literal["lambda"], region: str | None = ...
322323
) -> LambdaClient: ...
323324

325+
@overload
326+
def client(
327+
self, name: Literal["pricing"], region: str | None = ...
328+
) -> PricingClient: ...
329+
324330
@overload
325331
def client(
326332
self, name: str, region: str | None = ...
@@ -339,6 +345,7 @@ def client(
339345
| ECRClient
340346
| IAMClient
341347
| LambdaClient
348+
| PricingClient
342349
| botocore.client.BaseClient
343350
):
344351
"""Get a client.

src/e3/aws/pricing/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from typing import TYPE_CHECKING
1010

1111
if TYPE_CHECKING:
12-
import botocore
12+
from types_boto3_pricing import PricingClient
13+
from types_boto3_pricing.type_defs import FilterTypeDef
1314

1415
from typing import Any
1516

@@ -22,7 +23,7 @@
2223
class Pricing:
2324
"""Pricing abstraction."""
2425

25-
def __init__(self, client: botocore.client.BaseClient) -> None:
26+
def __init__(self, client: PricingClient) -> None:
2627
"""Initialize Pricing.
2728
2829
:param client: a client for the Pricing API
@@ -51,7 +52,7 @@ def ec2_price_information(
5152
instance_type: str | None = None,
5253
os: str | None = None,
5354
region: str | None = None,
54-
filters: list[dict[str, Any]] | None = None,
55+
filters: list[FilterTypeDef] | None = None,
5556
) -> list[PriceInformation]:
5657
"""Get pricing informations for EC2 instances.
5758

0 commit comments

Comments
 (0)