{"id":2612,"library":"mypy-boto3-textract","title":"mypy-boto3-textract","description":"mypy-boto3-textract provides a complete set of type annotations for the boto3 Textract service. These stubs enable static type checking for boto3 client operations, improving code quality and developer experience by catching type-related errors at development time. It is generated by the mypy-boto3-builder project and typically releases new versions in sync with boto3 updates, currently at 1.42.3.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","textract","mypy","type-hinting","stubs"],"install":[{"cmd":"pip install mypy-boto3-textract","lang":"bash","label":"Install stubs and boto3 runtime"}],"dependencies":[{"reason":"Runtime dependency for the AWS SDK for Python, which these stubs augment. `mypy-boto3-textract` explicitly depends on a compatible `boto3` version.","package":"boto3","optional":false}],"imports":[{"note":"While `boto3.client('textract')` is the correct runtime instantiation, importing `TextractClient` allows for precise type-hinting of the client variable for static analysis.","wrong":"import boto3; client = boto3.client('textract')","symbol":"TextractClient","correct":"from mypy_boto3_textract.client import TextractClient"},{"note":"Type definitions for Textract service request and response payloads are available for detailed type-hinting.","symbol":"AnalyzeDocumentResponseTypeDef","correct":"from mypy_boto3_textract.type_defs import AnalyzeDocumentResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_textract.client import TextractClient\nfrom mypy_boto3_textract.type_defs import AnalyzeDocumentResponseTypeDef, DocumentTypeDef # Import for detailed typing\n\ndef get_typed_textract_client() -> TextractClient:\n    \"\"\"\n    Demonstrates how to obtain a type-hinted Textract client.\n    The actual boto3 client is created, and the `TextractClient` type stub\n    provides static analysis for its methods.\n    \"\"\"\n    # boto3 automatically handles authentication via environment variables\n    # (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) or other credential providers.\n    # No explicit os.environ.get is typically needed here for the stubs to function,\n    # as they primarily assist static analysis, not runtime credential fetching.\n    client: TextractClient = boto3.client(\"textract\", region_name=\"us-east-1\") # Specify region for a valid client\n    print(f\"Successfully obtained a type-hinted Textract client: {type(client)}\")\n    # You can now use 'client' with full type-hinting support\n    # For example, client.analyze_document(...)\n    return client\n\nif __name__ == '__main__':\n    typed_client = get_typed_textract_client()\n    # At this point, `typed_client` has all the type hints for the Textract service,\n    # enabling static analysis in your IDE or with mypy.\n    # A live call (e.g., typed_client.analyze_document(...)) would require\n    # valid AWS credentials and appropriate permissions at runtime.\n","lang":"python","description":"This quickstart demonstrates the core functionality of `mypy-boto3-textract`: obtaining a type-hinted `boto3` client for the Textract service. It showcases the import of the `TextractClient` type and its application when creating a `boto3.client` instance, enabling comprehensive static analysis of Textract operations without requiring live AWS credentials for the type-checking benefit itself."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher to use newer versions of `mypy-boto3-textract`.","message":"Support for Python 3.8 was officially removed with `mypy-boto3-builder` version 8.12.0. Consequently, `mypy-boto3-textract` versions generated by this builder or newer will not support Python 3.8.","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Update imports and references to the new, shortened TypeDef names. Refer to the specific service's `type_defs.pyi` file (e.g., `mypy_boto3_textract.type_defs`) for corrected names.","message":"Type definition (TypeDef) names were shortened and modified in `mypy-boto3-builder` version 8.9.0. This caused changes like `CreateDistributionRequestRequestTypeDef` becoming `CreateDistributionRequestTypeDef`. Code directly importing or referencing these specific TypeDef names will break.","severity":"breaking","affected_versions":">=8.9.0"},{"fix":"Verify your `boto3` version (`pip show boto3`) aligns with the range required by `mypy-boto3-textract`. If issues persist, try upgrading `boto3`.","message":"Ensure your `boto3` runtime package version is compatible with `mypy-boto3-textract`. While `mypy-boto3-textract` specifies `boto3` as a dependency, explicitly managing `boto3` versions (e.g., `boto3>=1.42.0,<2.0.0`) can prevent unexpected type-checking or runtime errors if mismatches occur.","severity":"gotcha","affected_versions":"all"},{"fix":"Most users will not need to take action. If encountering issues with custom build tools or environments, consult the `mypy-boto3-builder` documentation or upgrade your tooling.","message":"All `mypy-boto3` packages, including `mypy-boto3-textract`, migrated to PEP 561 compliance (marked with `py.typed`) in `mypy-boto3-builder` version 8.12.0. While this is an improvement for type checkers, older build systems or custom tooling might require updates to properly handle this new package structure.","severity":"gotcha","affected_versions":">=8.12.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}