Closed
Description
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 parse
static method into a class method and making it return cls(**version_parts)
the result of parse will be an instance of the subclass (my class), not the superclass (VersionInfo).
e.g:
class MyBogusVersionInfo(semver.VersionInfo):
@classmethod
def parse(cls, version):
if version.startswith("foobar"):
version = version[6:]
return super().parse(version)
print(type(MyBogusVersionInfo.parse("1.2.3")))
Current result is : <class 'semver.VersionInfo'>
, while I would have expected <class 'MyBogusVersionInfo'>
Metadata
Metadata
Assignees
Labels
Issue depends on a different issue or cannot be solved ATMIssue depends on a different issue or cannot be solved ATMNot a bug, but increases or improves in value, quality, desirability, or attractivenessNot a bug, but increases or improves in value, quality, desirability, or attractivenessUnclear or open issue subject for debateUnclear or open issue subject for debate