{"id":3143,"library":"mypy-boto3-servicediscovery","title":"Type Annotations for boto3 ServiceDiscovery","description":"mypy-boto3-servicediscovery provides high-quality type annotations for the `boto3` ServiceDiscovery client, paginators, and type definitions. It is part of the `boto3-stubs` project, generated by `mypy-boto3-builder 8.12.0`, and is currently at version 1.42.3. The project maintains an active release cadence, frequently updating to match new `boto3` versions and incorporate fixes.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","type-hints","servicediscovery","stubs"],"install":[{"cmd":"pip install mypy-boto3-servicediscovery","lang":"bash","label":"Install specific service annotations"},{"cmd":"pip install 'boto3-stubs[servicediscovery]'","lang":"bash","label":"Install via consolidated boto3-stubs package"}],"dependencies":[{"reason":"This package provides type annotations for boto3's ServiceDiscovery client; boto3 itself is a runtime dependency for your application.","package":"boto3","optional":false}],"imports":[{"symbol":"ServiceDiscoveryClient","correct":"from mypy_boto3_servicediscovery import ServiceDiscoveryClient"},{"note":"Paginator types reside in the '.paginator' submodule.","wrong":"from mypy_boto3_servicediscovery import ListNamespacesPaginator","symbol":"ListNamespacesPaginator","correct":"from mypy_boto3_servicediscovery.paginator import ListNamespacesPaginator"},{"note":"Type definitions (TypedDicts) are located in the '.type_defs' submodule.","wrong":"from mypy_boto3_servicediscovery import TagTypeDef","symbol":"TagTypeDef","correct":"from mypy_boto3_servicediscovery.type_defs import TagTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_servicediscovery import ServiceDiscoveryClient\nfrom mypy_boto3_servicediscovery.type_defs import ListNamespacesResponseTypeDef\n\ndef get_servicediscovery_namespaces() -> list[str]:\n    # Explicit type annotation for better IDE support and type checking\n    client: ServiceDiscoveryClient = boto3.client(\"servicediscovery\")\n\n    # The response object is also type-hinted\n    response: ListNamespacesResponseTypeDef = client.list_namespaces()\n    \n    namespace_names = [ns['Name'] for ns in response.get('Namespaces', []) if 'Name' in ns]\n    return namespace_names\n\nif __name__ == \"__main__\":\n    # This code requires AWS credentials to be configured (e.g., via AWS CLI, env vars)\n    # If no namespaces exist, it will return an empty list.\n    try:\n        namespaces = get_servicediscovery_namespaces()\n        print(f\"ServiceDiscovery Namespaces: {namespaces}\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-servicediscovery` to obtain a type-hinted ServiceDiscovery client from `boto3.client`. It then calls `list_namespaces` and leverages the provided type definitions for the response, enhancing code completion and static analysis."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Support for Python 3.8 has been officially removed starting with `mypy-boto3-builder 8.12.0` (which generated this package version). Users on Python 3.8 will encounter compatibility issues.","severity":"breaking","affected_versions":">= 1.42.0 (generated by builder 8.12.0)"},{"fix":"Review and update your explicit TypeDef references according to the new naming conventions, or rely on implicit type inference where possible.","message":"Type definition (TypeDef) naming conventions were changed in `mypy-boto3-builder 8.9.0`. Shorter names are now preferred, and 'Extra' postfixes are moved. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. If your code explicitly references these generated TypeDefs, it will break.","severity":"breaking","affected_versions":">= 1.42.0 (generated by builder 8.9.0+)"},{"fix":"Ensure your environment uses standard `pip install` or compatible tools. If encountering issues, refer to the `boto3-stubs` documentation for detailed installation and usage instructions.","message":"The entire `mypy-boto3-builder` ecosystem migrated to PEP 561 compliant packages in `8.12.0`. While this improves type checker discovery, it might affect custom build or package management setups that relied on older distribution methods.","severity":"breaking","affected_versions":">= 1.42.0 (generated by builder 8.12.0)"},{"fix":"Implement the `if TYPE_CHECKING:` block with an `else` branch that assigns `object` to the type symbols to avoid Pylint errors. Example: `if TYPE_CHECKING: from mypy_boto3_ec2 import EC2Client else: EC2Client = object`.","message":"For Pylint compatibility when using the `TYPE_CHECKING` flag to conditionally import types, Pylint might complain about undefined variables. A common workaround is to set types to `object` in the `else` branch.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Add explicit type annotations for client and resource objects when instantiating them from `boto3` or a `Session`.","message":"Although `boto3-stubs` offers implicit type discovery, explicit type annotations for `boto3.client(...)` and `session.client(...)` calls (e.g., `client: ServiceDiscoveryClient = session.client(\"servicediscovery\")`) are highly recommended for optimal IDE auto-completion and robust static analysis.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}