{"id":3619,"library":"mypy-boto3-m2","title":"mypy-boto3-m2 Type Stubs for AWS Mainframe Modernization","description":"mypy-boto3-m2 provides type annotations for the AWS Mainframe Modernization (M2) service within the boto3 library. These stubs enable static type checking for M2 clients and resources, enhancing developer productivity and catching type-related errors early. The current version is 1.42.3, generated by the mypy-boto3-builder, which maintains a regular release cadence to keep pace with boto3 updates.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","typing","stubs","mainframe-modernization","m2"],"install":[{"cmd":"pip install boto3 mypy-boto3-m2","lang":"bash","label":"Install boto3 and M2 stubs"}],"dependencies":[{"reason":"These packages provide type stubs for the boto3 library, so boto3 must be installed for them to be useful.","package":"boto3"}],"imports":[{"note":"For type-hinting the M2 client obtained from boto3.client.","symbol":"MainframeModernizationClient","correct":"from mypy_boto3_m2.client import MainframeModernizationClient"},{"note":"For explicit type-hinting of service-specific TypeDefs.","symbol":"CreateEnvironmentInputRequestTypeDef","correct":"from mypy_boto3_m2.type_defs import CreateEnvironmentInputRequestTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_m2.client import MainframeModernizationClient\n\n# Note: In a real application, consider using AWS STS or environment variables for credentials.\n# For a quickstart example, boto3 uses default credential chain (env vars, ~/.aws/credentials, etc.)\n\n# Get a typed M2 client\nm2_client: MainframeModernizationClient = boto3.client(\"m2\", region_name=\"us-east-1\")\n\ntry:\n    # Example: List environments (replace with an actual M2 operation you'd perform)\n    response = m2_client.list_environments(\n        maxResults=10\n    )\n    print(f\"Successfully listed {len(response.get('environments', []))} M2 environments.\")\n    # Type checkers will validate arguments and response structure due to stubs\nexcept Exception as e:\n    print(f\"Error listing M2 environments: {e}\")","lang":"python","description":"This quickstart demonstrates how to obtain a type-hinted AWS Mainframe Modernization client using `boto3` and the `mypy-boto3-m2` stubs, then performs a simple `list_environments` operation. Mypy will validate the client's methods and argument types."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. If you must use Python 3.8, pin `mypy-boto3-m2` to an older version (e.g., `<1.42.3`).","message":"Python 3.8 support was removed from mypy-boto3-builder (version 8.12.0) and consequently from all generated stub packages, including mypy-boto3-m2 1.42.3 and newer.","severity":"breaking","affected_versions":"mypy-boto3-m2 >=1.42.3"},{"fix":"Ensure your environment and type checker (e.g., `mypy`) are up-to-date and correctly configured to handle PEP 561 compliant stub packages. Reinstalling stub packages might resolve any discovery issues.","message":"The `mypy-boto3-builder` migrated to PEP 561 packaging (implicit namespace packages) starting with version 8.12.0. This change affects how type checkers discover and load stubs.","severity":"breaking","affected_versions":"mypy-boto3-m2 >=1.42.3"},{"fix":"Always install `boto3` alongside `mypy-boto3-m2`: `pip install boto3 mypy-boto3-m2`.","message":"These packages provide only type stubs. You must install the actual `boto3` library for your code to run at runtime.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For every AWS service you interact with via `boto3`, install its corresponding stub package (e.g., `mypy-boto3-s3` for S3, `mypy-boto3-ec2` for EC2).","message":"Each `mypy-boto3-<service_name>` package provides stubs only for its specific AWS service. If you use multiple AWS services, you need to install stubs for each of them.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review your code for explicit imports of TypeDefs (e.g., `from mypy_boto3_m2.type_defs import ...`). Consult the generated stub files or the builder's changelog for the new TypeDef names if you encounter `ImportError` or type checker errors.","message":"TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0 to resolve conflicts and shorten names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). If you explicitly import TypeDefs, their names might have changed.","severity":"breaking","affected_versions":"mypy-boto3-m2 >=1.42.3 (generated by builder >=8.9.0)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}