Skip to content

Supported dictionaries not reflected in type annotations #986

@PicardParis

Description

@PicardParis

Issue

Some methods support dictionaries but this is not reflected in the type annotations.

Example

This working code triggers a "dict[str, str]" cannot be assigned to type "ClientOptions | None" warning:

import google.cloud.documentai_v1 as documentai

client_options = dict(api_endpoint="eu-documentai.googleapis.com")
client = documentai.DocumentProcessorServiceClient(client_options=client_options)

In the client library generated source code, dictionaries are supported:

if isinstance(client_options, dict):
    client_options = client_options_lib.from_dict(client_options)

but the typing is incomplete:

client_options: Optional[client_options_lib.ClientOptions] = None,

Note: This is just an example. There are multiple similar occurrences in different client libraries (if isinstance(xxx, dict) could be a marker to find them).

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.type: docsImprovement to the documentation for an API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions