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#46635 — sdk/search/azure-search-documents/azure/search/documents/knowledgebases/models/_models.py, class KnowledgeBaseModelWebSummarizationActivityRecord.
Checklist
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:...models.MODEL_WEB_SUMMARIZATIONdoes not exist. It should reference the enum type (which is exported from the module)::vartype type: str or ~azure.search.documents.knowledgebases.models.KnowledgeBaseActivityRecordTypeReproduction
Regenerate any TypeSpec service with discriminated polymorphic models using
@azure-tools/typespec-python(observed in0.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#46635 —
sdk/search/azure-search-documents/azure/search/documents/knowledgebases/models/_models.py, classKnowledgeBaseModelWebSummarizationActivityRecord.Checklist