mypy-boto3-databrew Type Stubs
mypy-boto3-databrew provides comprehensive type annotations for the AWS GlueDataBrew service, enhancing developer experience with static type checking and IDE auto-completion for boto3. It is part of the `mypy-boto3-builder` ecosystem, which generates stubs for all AWS services. The library is actively maintained with frequent updates to align with boto3 releases and new AWS service features, typically on a monthly cadence.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequently in generated packages. Ensure your project uses Python 3.9 or newer.
- breaking TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). Conflicting `Extra` postfixes were moved to the end (`CreateDistributionExtraRequestTypeDef` to `CreateDistributionRequestExtraTypeDef`). This may require updates to explicit `TypedDict` imports in your code.
- gotcha For optimal performance and correct type resolution in PyCharm, especially with Literal overloads, it is recommended to use `boto3-stubs-lite` instead of the full stubs. Alternatively, disable PyCharm's internal type checker and rely on external tools like `mypy` or `pyright`.
- gotcha While `mypy-boto3-databrew` provides type information, `boto3` and `mypy` (or another type checker) must be installed separately for the stubs to be effective. The stubs do not include the runtime library itself.
- gotcha Explicit type annotations for `boto3.client()` calls are often recommended or necessary for the best type-checking and auto-completion experience, especially with IDEs like VSCode and PyCharm, as automatic type discovery may not always be fully reliable or performant.
Install
-
pip install mypy-boto3-databrew boto3 mypy -
pip install 'boto3-stubs[databrew]' boto3 mypy
Imports
- GlueDataBrewClient
from mypy_boto3_databrew.client import GlueDataBrewClient
- BatchPutDataBrewJobResponseTypeDef
from mypy_boto3_databrew.type_defs import BatchPutDataBrewJobResponseTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_databrew.client import GlueDataBrewClient
from mypy_boto3_databrew.type_defs import ListRecipesResponseTypeDef
def get_databrew_recipes() -> ListRecipesResponseTypeDef:
# Initialize the DataBrew client with type annotation
client: GlueDataBrewClient = boto3.client("databrew")
# Use the client with type-hinted methods and expected return types
response: ListRecipesResponseTypeDef = client.list_recipes(MaxResults=5)
print(f"Found {len(response['Recipes'])} DataBrew recipes.")
for recipe in response.get('Recipes', []):
print(f"- {recipe['Name']} (ARN: {recipe['Arn']})")
return response
if __name__ == "__main__":
# Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
# For a runnable example without actual AWS calls, you might mock boto3 or use a dummy client.
# This example assumes valid AWS credentials are set up.
print("Listing DataBrew recipes...")
try:
get_databrew_recipes()
except Exception as e:
print(f"Error fetching DataBrew recipes: {e}")
print("Please ensure AWS credentials and region are configured correctly.")