Skip to content

[Bug]: [http-client-python] Discriminator subclass :vartype points at non-existent symbol #10575

@hizixin

Description

@hizixin

Describe the bug

For every discriminator subclass, the generated :vartype type: docstring references the upper-cased discriminator value as if it were a module-level symbol. It isn't — the actual symbol is an enum member on the discriminator enum class — so the Sphinx cross-reference is unresolvable.

Example from generated azure-search-documents:

class KnowledgeBaseModelWebSummarizationActivityRecord(
    KnowledgeBaseActivityRecord, discriminator="modelWebSummarization"
):
    """...
    :vartype type: str or ~azure.search.documents.knowledgebases.models.MODEL_WEB_SUMMARIZATION
    """
    type: Literal[KnowledgeBaseActivityRecordType.MODEL_WEB_SUMMARIZATION] = rest_discriminator(...)

...models.MODEL_WEB_SUMMARIZATION does not exist. It should reference the enum type (which is exported from the module):

:vartype type: str or ~azure.search.documents.knowledgebases.models.KnowledgeBaseActivityRecordType

Reproduction

Regenerate any TypeSpec service with discriminated polymorphic models using @azure-tools/typespec-python (observed in 0.61.3). Any generated discriminator subclass shows :vartype type: ... ~<module>.<UPPER_CASED_DISCRIMINATOR_VALUE> pointing at a non-existent attribute.

Concrete instance: Azure/azure-sdk-for-python#46635sdk/search/azure-search-documents/azure/search/documents/knowledgebases/models/_models.py, class KnowledgeBaseModelWebSummarizationActivityRecord.

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingemitter:client:pythonIssue for the Python client emitter: @typespec/http-client-python

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions