Repository navigation
[http-client-python] Fix discriminator subclass :vartype pointing at non-existent symbol - #12127
Conversation
EnumValue.docstring_type built the Sphinx cross-reference from the enum member name (e.g. ~pkg.models.MODEL_WEB_SUMMARIZATION), which is not a symbol of the models module. Reference the enum class instead (~pkg.models.KnowledgeBaseActivityRecordType), matching EnumType. Fixes microsoft#10575 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Hi @Shivam Sharma (@ShivamSharma43). Your PR has had no update for 14 days and it is marked as a stale PR. If it is not updated within 14 additional days, the PR will automatically be closed. The |
|
Merged the latest |
commit: |
|
All changed packages have been documented.
Show changes
|
Python emitter diffBaseline Diff summary: 4 file(s), +6 / -6 Rendered diff: inline on the run summary, or the emitter-diff-html artifact. Informational check (eng/emitter-diff); does not block the PR. |
iscai-msft
left a comment
There was a problem hiding this comment.
looks great, thanks so much Shivam Sharma (@ShivamSharma43)! sorry for the delay in getting back to you. thank you so much for contributing, Libba Lawrence (@l0lawrence) do you know when the next python release is?
should be one later this month or early next month |
Summary
For discriminated subclasses, the generated
:vartypeof the discriminator property referenced the upper-cased enum member name as if it were a module-level symbol::vartype type: str or ~azure.search.documents.knowledgebases.models.MODEL_WEB_SUMMARIZATIONmodels.MODEL_WEB_SUMMARIZATIONdoes not exist, so the Sphinx cross-reference cannot resolve. With this change the docstring points at the discriminator enum class, which the models module does export::vartype type: str or ~azure.search.documents.knowledgebases.models.KnowledgeBaseActivityRecordTypeRoot cause
EnumValue.docstring_type()ingenerator/pygen/codegen/models/enum_type.pybuilt the reference asf"{client_namespace}.models.{self.name}", whereself.nameis the enum member's name, not the enum's. A discriminator property on a subclass is typed as a singleEnumValue, so every discriminator subclass got the bad reference. (The type annotation,Literal[KnowledgeBaseActivityRecordType.MODEL_WEB_SUMMARIZATION], was already correct.)Fix
Use
self.enum_type.nameso the reference points at the enum class. This matches whatEnumType.docstring_type()already produces for the base class.generation-subdirhandling is unchanged.Tests
Added to
tests/unit/test_typeddict.py, in the existingEnumValuesection:test_enum_value_docstring_type_references_enum_class: the docstring type isstr or ~<ns>.models.Colorand matches the parentEnumType's docstring type.test_enum_value_docstring_type_with_generation_subdir:generation-subdiris still included in the path.test_discriminator_vartype_references_enum_class:DpgModelSerializer.variable_documentation_stringon a discriminator property emits:vartype type: str or ~<ns>.models.ActivityRecordTypeand not the member name.All three fail on
main(for example,- ...models.ActivityRecordType/+ ...models.MODEL_WEB_SUMMARIZATION) and pass with this fix.black --checkandpylintare clean on the changed files. A chronus changeset (fix) is included.Fixes #10575
🤖 Generated with Claude Code