Skip to content

Commit

Permalink
Use types-boto3 for integration
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Nov 29, 2024
1 parent fb83c3f commit d0bd4ad
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: boto3-stubs integration
name: types-boto3 integration

on:
schedule:
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
cache: "pip"
- name: Install main packages
run: |
pip install mypy_boto3_output/boto3_stubs_package
pip install mypy_boto3_output/types_boto3_package
- name: Install dependencies
run: |
python -m pip install mypy ruff pyright boto3 botocore botocore-stubs types-requests
Expand Down
4 changes: 2 additions & 2 deletions examples/dynamodb_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Usage example for `mypy-boto3-dynamodb` package.
Usage example for `types-boto3-dynamodb` package.
```bash
pip install `boto3-stubs[dynamodb]`
pip install `types-boto3[dynamodb]`
mypy myproject
pyright myproject
```
Expand Down
4 changes: 2 additions & 2 deletions examples/ec2_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Usage example for `mypy-boto3-ec2` package.
Usage example for `types-boto3-ec2` package.
```bash
pip install `boto3-stubs[ec2]`
pip install `types-boto3[ec2]`
mypy myproject
pyright myproject
```
Expand Down
4 changes: 2 additions & 2 deletions examples/emr_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Usage example for `mypy-boto3-emr` package.
Usage example for `types-boto3-emr` package.
```bash
pip install `boto3-stubs[emr]`
pip install `types-boto3[emr]`
mypy myproject
pyright myproject
```
Expand Down
4 changes: 2 additions & 2 deletions examples/iam_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Usage example for `mypy-boto3-iam` package.
Usage example for `types-boto3-iam` package.
```bash
pip install `boto3-stubs[iam]`
pip install `types-boto3[iam]`
mypy myproject
pyright myproject
```
Expand Down
10 changes: 5 additions & 5 deletions examples/s3_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Usage example for `mypy-boto3-s3` package.
Usage example for `types-boto3-s3` package.
```bash
pip install `boto3-stubs[s3]`
pip install `types-boto3[s3]`
mypy myproject
pyright myproject
```
Expand All @@ -14,9 +14,9 @@
from boto3.session import Session

if TYPE_CHECKING:
from mypy_boto3_s3.client import S3Client
from mypy_boto3_s3.service_resource import Bucket, S3ServiceResource
from mypy_boto3_s3.type_defs import BucketUploadFileRequestTypeDef
from types_boto3_s3.client import S3Client
from types_boto3_s3.service_resource import Bucket, S3ServiceResource
from types_boto3_s3.type_defs import BucketUploadFileRequestTypeDef


def s3_resource_example() -> None:
Expand Down
4 changes: 2 additions & 2 deletions examples/secretsmanager_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Usage example for `mypy-boto3-secretsmanager` package.
Usage example for `types-boto3-secretsmanager` package.
```bash
pip install `boto3-stubs[secretsmanager]`
pip install `types-boto3[secretsmanager]`
mypy myproject
pyright myproject
```
Expand Down
6 changes: 3 additions & 3 deletions examples/sqs_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Usage example for `mypy-boto3-sqs` package.
Usage example for `types-boto3-sqs` package.
```bash
pip install `boto3-stubs[sqs]`
pip install `types-boto3[sqs]`
mypy myproject
pyright myproject
```
Expand All @@ -15,7 +15,7 @@ def sqs_resource_example() -> None:
"""
Usage example for SQSClient.
"""
resource = boto3.resource("sqs")
resource = boto3.resource(service_name="sqs")

queue = resource.Queue("my_queue")
message_list = queue.receive_messages()
Expand Down
30 changes: 19 additions & 11 deletions scripts/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class Product:
name: str
examples_path: Path
install_script_path: Path
build_product: str
build_product: BuilderProduct
prerequisites: tuple[str, ...] = ()
main_build_products: tuple[str, ...] = ()
main_build_products: tuple[BuilderProduct, ...] = ()


class ProductChoices(enum.Enum):
Expand All @@ -66,16 +66,16 @@ class ProductChoices(enum.Enum):
name="boto3",
examples_path=EXAMPLES_PATH,
install_script_path=SCRIPTS_PATH / "install.sh",
build_product="boto3-services",
main_build_products=("boto3",),
build_product=BuilderProduct.types_boto3_services,
main_build_products=(BuilderProduct.types_boto3,),
)
aioboto3 = Product(
name="aioboto3",
prerequisites=("aioboto3",),
examples_path=AIO_EXAMPLES_PATH,
install_script_path=SCRIPTS_PATH / "install_aiobotocore.sh",
build_product="aiobotocore-services",
main_build_products=("aioboto3", "aiobotocore"),
build_product=BuilderProduct.aiobotocore_services,
main_build_products=(BuilderProduct.aioboto3, BuilderProduct.aiobotocore),
)


Expand Down Expand Up @@ -196,13 +196,13 @@ def build_packages(
"""
Build and install stubs.
- boto3: `boto3-stubs`
- boto3: `types-boto3`
- aioboto3: `types-aioboto3` and `types-aiobotocore`
"""
if product.prerequisites:
check_call([sys.executable, "-m", "pip", "install", *product.prerequisites])

products = [BuilderProduct(i) for i in (*product.main_build_products, product.build_product)]
products = [*product.main_build_products, product.build_product]
run_builder(
BuilderCLINamespace(
log_level=log_level,
Expand Down Expand Up @@ -350,9 +350,17 @@ def main() -> None:
log_level=args.log_level,
)

for package_path in args.output_path.iterdir():
logger.info(f"Installing {print_path(package_path)}...")
check_call([sys.executable, "-m", "pip", "install", package_path.as_posix()])
install_paths = list(args.output_path.iterdir())
logger.info(f"Installing {' '.join(print_path(path) for path in install_paths)}...")
check_call(
[
sys.executable,
"-m",
"pip",
"install",
*(path.as_posix() for path in install_paths),
]
)

for service_name in service_names:
file_path = args.product.examples_path / f"{service_name}_example.py"
Expand Down
Loading

0 comments on commit d0bd4ad

Please sign in to comment.