Python Guidelines: Polymorphic base classes should use string discriminator typing
- 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
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