Skip to content

Python Guidelines: Polymorphic base classes should use string discriminator typing #9929

Description

@azure-sdk-automation

Bad code snippet:

        type: str

This comment is currently being flagged against the enum-string guideline, but that guideline is out of date for polymorphic base classes. The base class should keep the discriminator as a plain string type; only derived child models should use explicit extensible enum typing for the discriminator.

Good code snippet:

        type: str

Please update the Python model guideline to clarify that polymorphic base classes use str for the discriminator, while child classes may use Union[str, <ExtensibleEnum>] where appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions