Skip to content

Examples#

Index > Glue > Examples

Auto-generated documentation for Glue type annotations stubs module mypy-boto3-glue.

Client#

Implicit type annotations#

Can be used with boto3-stubs[glue] package installed.

Write your Glue code as usual, type checking and code completion should work out of the box.

# GlueClient usage example

from boto3.session import Session


session = Session()

client = session.client("glue")  # (1)
result = client.batch_create_partition()  # (2)
  1. client: GlueClient
  2. result: BatchCreatePartitionResponseTypeDef
# DescribeEntityPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("glue")  # (1)

paginator = client.get_paginator("describe_entity")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: GlueClient
  2. paginator: DescribeEntityPaginator
  3. item: DescribeEntityResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[glue] or a standalone mypy_boto3_glue package, you have to explicitly specify client: GlueClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# GlueClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_glue.client import GlueClient
from mypy_boto3_glue.type_defs import BatchCreatePartitionResponseTypeDef
from mypy_boto3_glue.type_defs import BatchCreatePartitionRequestRequestTypeDef


session = Session()

client: GlueClient = session.client("glue")

kwargs: BatchCreatePartitionRequestRequestTypeDef = {...}
result: BatchCreatePartitionResponseTypeDef = client.batch_create_partition(**kwargs)
# DescribeEntityPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_glue.client import GlueClient
from mypy_boto3_glue.paginator import DescribeEntityPaginator
from mypy_boto3_glue.type_defs import DescribeEntityResponseTypeDef


session = Session()
client: GlueClient = session.client("glue")

paginator: DescribeEntityPaginator = client.get_paginator("describe_entity")
for item in paginator.paginate(...):
    item: DescribeEntityResponseTypeDef
    print(item)