Type Annotations for boto3 AccessAnalyzer
mypy-boto3-accessanalyzer provides high-quality type annotations for the AWS boto3 AccessAnalyzer service, compatible with mypy, pyright, VSCode, and PyCharm. It is currently at version 1.42.85 and is generated by the mypy-boto3-builder, which has a frequent release cadence, often in sync with boto3 and botocore updates to reflect new AWS services and API changes.
Warnings
- breaking Python 3.8 support was removed for all `mypy-boto3-builder` generated packages, including `mypy-boto3-accessanalyzer`, starting with builder version 8.12.0.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. This affects direct imports of specific type definitions.
- gotcha When using Pylint with `TYPE_CHECKING` for conditional imports, Pylint might report undefined variables in the `else` block. This is a known issue with Pylint's handling of conditional typing.
- gotcha PyCharm users might experience slow performance or high CPU usage when using `mypy-boto3` stubs due to PyCharm's handling of `Literal` overloads (issue PY-40997).
- gotcha This package (`mypy-boto3-accessanalyzer`) is a standalone stub package for a specific service. For a more integrated approach, `boto3-stubs` with service-specific extras (`pip install 'boto3-stubs[accessanalyzer]'`) is often recommended, as it manages a consolidated `boto3` stub environment.
Install
-
pip install mypy-boto3-accessanalyzer boto3 mypy -
pip install 'boto3-stubs[accessanalyzer]' boto3 mypy
Imports
- AccessAnalyzerClient
from mypy_boto3_accessanalyzer.client import AccessAnalyzerClient
- AccessAnalyzerServiceName
from mypy_boto3_accessanalyzer.literals import AccessAnalyzerServiceName
- ListAnalyzersResponseTypeDef
from mypy_boto3_accessanalyzer.type_defs import ListAnalyzersResponseTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_accessanalyzer.client import AccessAnalyzerClient
from mypy_boto3_accessanalyzer.type_defs import ListAnalyzersResponseTypeDef
def get_accessanalyzer_client() -> AccessAnalyzerClient:
"""Returns a type-hinted AccessAnalyzer client."""
# boto3 client creation remains the same
client: AccessAnalyzerClient = boto3.client("accessanalyzer")
return client
if __name__ == "__main__":
# Example usage
client = get_accessanalyzer_client()
# The client now has full type hints for methods and their parameters/returns.
# For instance, client.list_analyzers() is type-checked.
response: ListAnalyzersResponseTypeDef = client.list_analyzers()
print(f"Found {len(response.get('analyzers', []))} Access Analyzers.")