Azure / Azure/azure-sdk

Python Guidelines: Polymorphic base classes should use string discriminator typing

Open Beginner friendly
#9,929 0 comments 0 reactions 0 assignees View on GitHub
customer-reported needs-triage question
Dominant language
PowerShell
Stars
597
Forks
374
Avg merge
5d 21h
Merged PRs (30d)
42

Description

Bad code snippet:
```Python
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:
```Python
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, ]` where appropriate.

Contributor guide

Open the contributing guide

Research direction

Locate the Python model guideline and review the current enum-string guidance for polymorphic base classes. Clarify that base-class discriminators use str, while child classes may use Union[str, ] where appropriate. Done means the guideline distinguishes these cases and no longer flags the shown base-class pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.