{"id":8735,"library":"types-aiobotocore-textract","title":"Type Annotations for aiobotocore Textract","description":"This library provides static type annotations for the `aiobotocore` Textract service client, enhancing code reliability through static type checking with tools like MyPy and Pyright. It is currently at version 3.4.0 and is generated by `mypy-boto3-builder 8.12.0`, receiving frequent updates in sync with new `aiobotocore` releases and builder improvements.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","Textract","aiobotocore","type-annotations","mypy","pyright","stubs"],"install":[{"cmd":"pip install types-aiobotocore-textract","lang":"bash","label":"Install only Textract stubs"},{"cmd":"pip install 'types-aiobotocore[textract]'","lang":"bash","label":"Install Textract stubs with main types-aiobotocore package"}],"dependencies":[{"reason":"This package provides type stubs for aiobotocore; the actual aiobotocore library is required for runtime functionality.","package":"aiobotocore","optional":false},{"reason":"Required for static type checking in a development environment.","package":"mypy","optional":true},{"reason":"Alternative static type checker, compatible with these stubs.","package":"pyright","optional":true}],"imports":[{"note":"Imports the typed client class for Textract.","symbol":"TextractClient","correct":"from types_aiobotocore_textract.client import TextractClient"},{"note":"Imports a specific TypedDict for Textract API responses.","symbol":"AdapterOverviewTypeDef","correct":"from types_aiobotocore_textract.type_defs import AdapterOverviewTypeDef"},{"note":"Imports a Literal type for Textract enumeration values.","symbol":"AdapterVersionStatusType","correct":"from types_aiobotocore_textract.literals import AdapterVersionStatusType"},{"note":"The entry point for creating aiobotocore clients.","symbol":"get_session","correct":"from aiobotocore.session import get_session"}],"quickstart":{"code":"import asyncio\nfrom aiobotocore.session import get_session\nfrom types_aiobotocore_textract.client import TextractClient\n\nasync def analyze_document_typed(s3_bucket: str, s3_key: str):\n    session = get_session()\n    async with session.create_client(\"textract\") as client:  # type: TextractClient\n        print(f\"Client type: {type(client)}\")\n        try:\n            response = await client.analyze_document(\n                Document={\n                    'S3Object': {\n                        'Bucket': s3_bucket,\n                        'Name': s3_key\n                    }\n                },\n                FeatureTypes=['FORMS', 'TABLES']\n            )\n            print(\"Document analysis successful.\")\n            # Example of accessing a typed response\n            document_metadata = response.get('DocumentMetadata')\n            if document_metadata:\n                print(f\"Pages: {document_metadata.get('Pages')}\")\n        except client.ValidationException as e:\n            print(f\"Validation error: {e}\")\n        except Exception as e:\n            print(f\"An unexpected error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    # Replace with your S3 bucket and key for a document (e.g., PDF, PNG, JPG)\n    # This example requires an actual S3 object for Textract to process.\n    # For local testing without a real S3 object, Textract might raise an InvalidS3ObjectException or similar.\n    dummy_s3_bucket = \"your-s3-bucket\"\n    dummy_s3_key = \"path/to/your/document.pdf\"\n    # You can use a dummy value if you only want to test type checking without actual execution\n    # or ensure a real, accessible S3 object is configured for Textract.\n    asyncio.run(analyze_document_typed(dummy_s3_bucket, dummy_s3_key))\n","lang":"python","description":"This quickstart demonstrates how to initialize an `aiobotocore` Textract client and use it with type annotations provided by `types-aiobotocore-textract`. The example calls `analyze_document` with dummy S3 object details. For a successful run, replace `dummy_s3_bucket` and `dummy_s3_key` with actual values pointing to a document in an S3 bucket accessible by your AWS credentials."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. Users on Python 3.8 or older will need to use an older stub version or migrate their Python environment.","message":"Python 3.8 support was removed from `mypy-boto3-builder` (which generates these stubs) in version 8.12.0. As `types-aiobotocore-textract 3.4.0` is generated with builder version 8.12.0, it explicitly requires Python 3.9 or newer.","severity":"breaking","affected_versions":">=3.4.0"},{"fix":"Review your code for any custom TypeDef imports or direct references that might have been affected by the naming change and update them accordingly. Consult the specific service's `type_defs.pyi` for the correct names.","message":"The `mypy-boto3-builder` (version 8.9.0 and newer) introduced breaking changes to TypeDef naming conventions. This includes shortening names for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and moving `Extra` postfixes. Code explicitly importing and using these TypeDefs may break.","severity":"breaking","affected_versions":">=3.4.0"},{"fix":"Ensure `aiobotocore` is installed in your environment alongside the type stubs: `pip install aiobotocore`. For type checking, `mypy` or `pyright` are also required as development dependencies.","message":"These `types-aiobotocore-*` packages provide only type annotations (stubs). They do not replace or include the actual `aiobotocore` runtime library. You must install `aiobotocore` separately for your code to function at runtime.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure your type checker (e.g., MyPy, Pyright) is up-to-date and correctly configured to find PEP 561-style stub packages. Most common setups should work without manual intervention.","message":"The `mypy-boto3-builder` ecosystem (which includes `types-aiobotocore`) migrated to PEP 561-compliant packages in version 8.12.0. While this generally improves compatibility and discovery, some older tools or custom configurations that relied on previous stub discovery mechanisms might require adjustments.","severity":"gotcha","affected_versions":">=3.4.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install `aiobotocore`: `pip install aiobotocore`.","cause":"The `types-aiobotocore-textract` package provides only type annotations; it does not include the actual `aiobotocore` runtime library.","error":"ModuleNotFoundError: No module named 'aiobotocore'"},{"fix":"Ensure `types-aiobotocore-textract` is installed, your type checker (MyPy) is up-to-date, and configured to recognize PEP 561 packages. You might also need `pip install 'types-aiobotocore[textract]'` if using the main `types-aiobotocore` package, or explicitly configure `MYPYPATH` if your environment is unusual.","cause":"This error occurs when MyPy cannot locate the type stubs, often due to an incorrect installation, an outdated type checker, or issues with PEP 561 package discovery.","error":"mypy: error: Cannot find implementation or library stub for module 'types_aiobotocore_textract.client'"},{"fix":"Ensure both `aiobotocore` and `types-aiobotocore-textract` are at compatible versions. You can also explicitly type the client after creation, e.g., `client: TextractClient = await session.create_client(\"textract\")`, to help the type checker. Check Textract service methods in the official AWS Boto3/Botocore documentation to confirm the method name.","cause":"This typically indicates that the type checker is not correctly applying the `TextractClient` type to your client object, or you might be using an `aiobotocore` version that is incompatible with the installed stubs, leading to an incorrect interface being presented.","error":"mypy: error: 'TextractClient' object has no attribute 'analyze_document' (note: perhaps you meant 'analyze_expense')"}]}