-
Notifications
You must be signed in to change notification settings - Fork 96
VersionInfo.parse should be a class method #276
Copy link
Copy link
Closed
Labels
BlockedIssue depends on a different issue or cannot be solved ATMIssue depends on a different issue or cannot be solved ATMEnhancementNot a bug, but increases or improves in value, quality, desirability, or attractivenessNot a bug, but increases or improves in value, quality, desirability, or attractivenessQuestionUnclear or open issue subject for debateUnclear or open issue subject for debate
Metadata
Metadata
Assignees
Labels
BlockedIssue depends on a different issue or cannot be solved ATMIssue depends on a different issue or cannot be solved ATMEnhancementNot a bug, but increases or improves in value, quality, desirability, or attractivenessNot a bug, but increases or improves in value, quality, desirability, or attractivenessQuestionUnclear or open issue subject for debateUnclear or open issue subject for debate
I wanted to create a subclass of VersionInfo for company reasons (more checkings, more methods, etc) and it turned out the VersionInfo.parse is a staticmethod, always returning VersionInfo instances, no matter what.
By turning the
parsestatic method into a class method and making itreturn cls(**version_parts)the result of parse will be an instance of the subclass (my class), not the superclass (VersionInfo).e.g:
Current result is :
<class 'semver.VersionInfo'>, while I would have expected<class 'MyBogusVersionInfo'>