Skip to content

Commit

Permalink
Refactor SchemaVersion based on PEP440Version
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Aug 20, 2023
1 parent 64b72a3 commit b24f3b3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions package_control/providers/schema_version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from ..deps.semver import SemVer
from ..pep440 import PEP440Version


class SchemaVersion(SemVer):
class SchemaVersion(PEP440Version):
supported_versions = ('2.0', '3.0.0', '4.0.0')

@classmethod
def _parse(cls, ver):
def __init__(self, ver):
"""
Custom version string parsing to maintain backward compatibility.
Expand All @@ -25,13 +24,10 @@ def _parse(cls, ver):
except ValueError:
raise ValueError('the "schema_version" is not a valid number.')

if ver not in cls.supported_versions:
if ver not in self.supported_versions:
raise ValueError(
'the "schema_version" is not recognized. Must be one of: %s or %s.'
% (', '.join(cls.supported_versions[:-1]), cls.supported_versions[-1])
% (', '.join(self.supported_versions[:-1]), self.supported_versions[-1])
)

if ver.count('.') == 1:
ver += '.0'

return SemVer._parse(ver)
super().__init__(ver)

0 comments on commit b24f3b3

Please sign in to comment.