-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
1,767 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Usage example for `types-boto3-dynamodb` package. | ||
```bash | ||
pip install `types-boto3[dynamodb]` | ||
mypy myproject | ||
pyright myproject | ||
``` | ||
""" | ||
|
||
import decimal | ||
|
||
import boto3 | ||
from boto3.dynamodb.conditions import Key | ||
|
||
|
||
def dynamodb_client_example() -> None: | ||
""" | ||
Usage example for DynamoDBClient. | ||
""" | ||
client = boto3.client("dynamodb") | ||
resource = boto3.resource("dynamodb") | ||
|
||
my_table = resource.Table("my_table") | ||
print(my_table.name) | ||
batch_writer = my_table.batch_writer() | ||
batch_writer.delete_item(Key={"HashKey": "123"}) | ||
|
||
my_table.put_item( | ||
Item={ | ||
"str": "value", | ||
"number": 123, | ||
"decimal": decimal.Decimal(123.2), | ||
"exception": ValueError("test"), | ||
} | ||
) | ||
|
||
try: | ||
client.list_backups(TableName=123) | ||
except client.exceptions.BackupInUseException as e: | ||
print(e) | ||
|
||
key_exp = Key("partition_key").eq("pk") & Key("time").between(888888, 999999) | ||
my_table.query(IndexName="my_table", FilterExpression=key_exp) | ||
|
||
keys = [{"pk": "abc", "sk": "def"}] | ||
resource.batch_get_item(RequestItems={"table": {"Keys": keys}}) | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Run examples. | ||
""" | ||
dynamodb_client_example() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
""" | ||
Usage example for `types-boto3-ec2` package. | ||
```bash | ||
pip install `types-boto3[ec2]` | ||
mypy myproject | ||
pyright myproject | ||
``` | ||
""" | ||
|
||
import boto3 | ||
from boto3.session import Session | ||
|
||
|
||
def ec2_resource_example() -> None: | ||
""" | ||
Usage example for EC2ServiceResource. | ||
""" | ||
session = Session(region_name="us-west-1") | ||
|
||
resource = session.resource("ec2") | ||
boto3_resource = boto3.resource("ec2") | ||
print(boto3_resource) | ||
|
||
# (mypy) error: Missing positional argument "Resources" in call | ||
# to "create_tags" of "ServiceResource" | ||
# (mypy) error: Argument "Tags" to "create_tags" of "ServiceResource" | ||
# has incompatible type "int"; expected "List[Tag]" | ||
resource.create_tags(Tags=123) | ||
|
||
vpc = resource.Vpc("foo") | ||
vpc_peer = vpc.request_vpc_peering_connection(PeerVpcId="bar") | ||
vpc_peer.accepter_vpc.delete(DryRun="incorrect") | ||
|
||
image = resource.Image(id="test") | ||
image.create_tags(Tags=[]) | ||
resource.meta.client.create_tags(Tags=[{"Key": 123}], Resources=[]) | ||
|
||
|
||
def ec2_client_example() -> None: | ||
""" | ||
Usage example for EC2Client. | ||
""" | ||
client = boto3.client("ec2") | ||
|
||
# (mypy) error: Incompatible types (expression has type "int", TypedDict item | ||
# "Key" has type "str") | ||
client.create_tags(Tags=[{"Key": 123}], Resources=[]) | ||
region_name = client.meta.region_name | ||
print(region_name) | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Run examples. | ||
""" | ||
ec2_resource_example() | ||
ec2_client_example() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Usage example for `types-boto3-emr` package. | ||
```bash | ||
pip install `types-boto3[emr]` | ||
mypy myproject | ||
pyright myproject | ||
``` | ||
""" | ||
|
||
import boto3 | ||
|
||
|
||
def emr_client_example() -> None: | ||
""" | ||
Usage example for EMRClient. | ||
""" | ||
client = boto3.client("emr") | ||
client.cancel_steps(ClusterId="cluster_id", StepIds=[123]) | ||
|
||
list_steps_paginator = client.get_paginator("list_steps") | ||
pages = list_steps_paginator.paginate(ClusterId="cluster_id") | ||
pages.build_full_result("test") | ||
for page in pages: | ||
print(page["Marker"]) | ||
for step in page["steps"]: | ||
print(step) | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Run examples. | ||
""" | ||
emr_client_example() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Usage example for `types-boto3-iam` package. | ||
```bash | ||
pip install `types-boto3[iam]` | ||
mypy myproject | ||
pyright myproject | ||
``` | ||
""" | ||
|
||
import boto3 | ||
|
||
|
||
def iam_client_example() -> None: | ||
""" | ||
Usage example for IAMClient. | ||
""" | ||
client = boto3.client("iam") | ||
client.add_user_to_group(GroupName="group", UserName=123) | ||
|
||
list_steps_paginator = client.get_paginator("get_account_authorization_details") | ||
pages = list_steps_paginator.paginate(ClusterId="cluster_id") | ||
for page in pages: | ||
print(page["Marker"]) | ||
for role in page["RoleDetail"]: | ||
print(role) | ||
|
||
|
||
def iam_resource_example() -> None: | ||
""" | ||
Usage example for IAMServiceResource. | ||
""" | ||
resource = boto3.resource("iam") | ||
group = resource.Group("my") | ||
group.add_user(UserName="my_user", Other=123) | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Run examples. | ||
""" | ||
iam_client_example() | ||
iam_resource_example() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
integration/boto3_stubs/dynamodb_example.py:34: error: Dict entry 3 has incompatible type "str": "ValueError"; expected "str": "bytes | bytearray | str | int | Decimal | <7 more items> | None" [dict-item] | ||
integration/boto3_stubs/dynamodb_example.py:39: error: Argument "TableName" to "list_backups" of "DynamoDBClient" has incompatible type "int"; expected "str" [arg-type] | ||
Found 2 errors in 1 file (checked 1 source file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
integration/boto3_stubs/ec2_example.py:29: error: Missing named argument "Resources" for "create_tags" of "EC2ServiceResource" [call-arg] | ||
integration/boto3_stubs/ec2_example.py:29: error: Argument "Tags" to "create_tags" of "EC2ServiceResource" has incompatible type "int"; expected "Sequence[TagTypeDef]" [arg-type] | ||
integration/boto3_stubs/ec2_example.py:33: error: Argument "DryRun" to "delete" of "Vpc" has incompatible type "str"; expected "bool" [arg-type] | ||
integration/boto3_stubs/ec2_example.py:37: error: Incompatible types (expression has type "int", TypedDict item "Key" has type "str") [typeddict-item] | ||
integration/boto3_stubs/ec2_example.py:48: error: Incompatible types (expression has type "int", TypedDict item "Key" has type "str") [typeddict-item] | ||
Found 5 errors in 1 file (checked 1 source file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
integration/boto3_stubs/emr_example.py:19: error: List item 0 has incompatible type "int"; expected "str" [list-item] | ||
integration/boto3_stubs/emr_example.py:23: error: Too many arguments for "build_full_result" of "PageIterator" [call-arg] | ||
integration/boto3_stubs/emr_example.py:26: error: TypedDict "ListStepsOutputTypeDef" has no key "steps" [typeddict-item] | ||
integration/boto3_stubs/emr_example.py:26: note: Did you mean "Steps"? | ||
Found 3 errors in 1 file (checked 1 source file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
integration/boto3_stubs/iam_example.py:19: error: Argument "UserName" to "add_user_to_group" of "IAMClient" has incompatible type "int"; expected "str" [arg-type] | ||
integration/boto3_stubs/iam_example.py:22: error: Unexpected keyword argument "ClusterId" for "paginate" of "GetAccountAuthorizationDetailsPaginator" [call-arg] | ||
integration/boto3_stubs/iam_example.py:25: error: TypedDict "GetAccountAuthorizationDetailsResponseTypeDef" has no key "RoleDetail" [typeddict-item] | ||
integration/boto3_stubs/iam_example.py:25: note: Did you mean "RoleDetailList"? | ||
integration/boto3_stubs/iam_example.py:35: error: Unexpected keyword argument "Other" for "add_user" of "Group" [call-arg] | ||
Found 4 errors in 1 file (checked 1 source file) |
Oops, something went wrong.