mypy-boto3-tnb
mypy-boto3-tnb provides type annotations for the `boto3` TelcoNetworkBuilder (TNB) service. It is part of the `mypy-boto3` ecosystem, generated by `mypy-boto3-builder`, offering enhanced type checking and IDE auto-completion for `boto3` clients and related objects. The `mypy-boto3` project maintains a frequent release cadence, typically releasing updates monthly or bi-monthly to keep pace with `boto3` and `botocore` changes.
Warnings
- breaking Python 3.8 support was removed with `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will need to upgrade to Python 3.9 or newer to use newly generated stubs.
- breaking The `mypy-boto3` ecosystem migrated to PEP 561 compliant packages with `mypy-boto3-builder` 8.12.0. While this generally improves type checker compatibility, ensure your type checker (e.g., MyPy, Pyright) is up-to-date to properly discover the new package structure.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Some `TypeDef` names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) or had postfixes moved, which can break explicit `TypeDef` imports.
- gotcha This library provides *only* type annotations. You must still install the `boto3` runtime library (e.g., `pip install boto3`) for your code to function at runtime.
- gotcha For optimal type checking, especially with standalone stub packages like `mypy-boto3-tnb`, it is recommended to explicitly annotate `boto3.client()` and `boto3.resource()` calls with the imported client types. While some IDEs might infer types, explicit annotations ensure consistent and reliable type checking across tools.
Install
-
pip install mypy-boto3-tnb boto3
Imports
- TelcoNetworkBuilderClient
from mypy_boto3_tnb.client import TelcoNetworkBuilderClient
- CreateSolFunctionPackageInputRequestTypeDef
from mypy_boto3_tnb.type_defs import CreateSolFunctionPackageInputRequestTypeDef
- TnbClient
from mypy_boto3_tnb import TNBClient
Quickstart
import boto3
from mypy_boto3_tnb.client import TelcoNetworkBuilderClient
from mypy_boto3_tnb.type_defs import CreateSolFunctionPackageOutputTypeDef
def create_tnb_function_package(package_name: str) -> CreateSolFunctionPackageOutputTypeDef:
# mypy-boto3-tnb provides type hints, boto3 is the runtime
client: TelcoNetworkBuilderClient = boto3.client("tnb")
# Example API call with type hinting for input and output
response: CreateSolFunctionPackageOutputTypeDef = client.create_sol_function_package(
tags={
"Name": package_name
}
)
print(f"Successfully created SOL Function Package: {response.get('id')}")
return response
if __name__ == "__main__":
# This code is for demonstration and requires AWS credentials configured
# It will attempt to create a resource, which may incur costs.
# Replace 'my-test-package' with a unique name.
try:
package_output = create_tnb_function_package("my-test-package")
# Additional operations with package_output can be typed here
except Exception as e:
print(f"An error occurred: {e}")