diff --git a/src/pycalver/patterns.py b/src/pycalver/patterns.py index 67e63a3..3b36dee 100644 --- a/src/pycalver/patterns.py +++ b/src/pycalver/patterns.py @@ -185,34 +185,35 @@ FULL_PART_FORMATS = { } -PART_FORMATS = { - 'major' : "[0-9]+", - 'minor' : "[0-9]{3,}", - 'patch' : "[0-9]{3,}", - 'bid' : "[0-9]{4,}", - 'MAJOR' : "[0-9]+", - 'MINOR' : "[0-9]+", - 'MM' : "[0-9]{2,}", - 'MMM' : "[0-9]{3,}", - 'MMMM' : "[0-9]{4,}", - 'MMMMM' : "[0-9]{5,}", - 'MMMMMM' : "[0-9]{6,}", - 'MMMMMMM': "[0-9]{7,}", - 'PATCH' : "[0-9]+", - 'PP' : "[0-9]{2,}", - 'PPP' : "[0-9]{3,}", - 'PPPP' : "[0-9]{4,}", - 'PPPPP' : "[0-9]{5,}", - 'PPPPPP' : "[0-9]{6,}", - 'PPPPPPP': "[0-9]{7,}", - 'BID' : "[1-9][0-9]*", - 'BB' : "[1-9][0-9]{1,}", - 'BBB' : "[1-9][0-9]{2,}", - 'BBBB' : "[1-9][0-9]{3,}", - 'BBBBB' : "[1-9][0-9]{4,}", - 'BBBBBB' : "[1-9][0-9]{5,}", - 'BBBBBBB': "[1-9][0-9]{6,}", -} +# TODO (mb 2020-09-17): I think this is garbage +# PART_FORMATS = { +# 'major' : "[0-9]+", +# 'minor' : "[0-9]{3,}", +# 'patch' : "[0-9]{3,}", +# 'bid' : "[0-9]{4,}", +# 'MAJOR' : "[0-9]+", +# 'MINOR' : "[0-9]+", +# 'MM' : "[0-9]{2,}", +# 'MMM' : "[0-9]{3,}", +# 'MMMM' : "[0-9]{4,}", +# 'MMMMM' : "[0-9]{5,}", +# 'MMMMMM' : "[0-9]{6,}", +# 'MMMMMMM': "[0-9]{7,}", +# 'PATCH' : "[0-9]+", +# 'PP' : "[0-9]{2,}", +# 'PPP' : "[0-9]{3,}", +# 'PPPP' : "[0-9]{4,}", +# 'PPPPP' : "[0-9]{5,}", +# 'PPPPPP' : "[0-9]{6,}", +# 'PPPPPPP': "[0-9]{7,}", +# 'BID' : "[1-9][0-9]*", +# 'BB' : "[1-9][0-9]{1,}", +# 'BBB' : "[1-9][0-9]{2,}", +# 'BBBB' : "[1-9][0-9]{3,}", +# 'BBBBB' : "[1-9][0-9]{4,}", +# 'BBBBBB' : "[1-9][0-9]{5,}", +# 'BBBBBBB': "[1-9][0-9]{6,}", +# } class Pattern(typ.NamedTuple): diff --git a/src/pycalver/version.py b/src/pycalver/version.py index fef0c58..6bf8658 100644 --- a/src/pycalver/version.py +++ b/src/pycalver/version.py @@ -245,8 +245,8 @@ def _parse_pattern_groups(pattern_groups: PatternGroups) -> FieldValues: if any(duplicate_fields): err_msg = f"Multiple parts for same field {duplicate_fields}." raise PatternError(err_msg) - - return dict(field_value_items) + else: + return dict(field_value_items) def _parse_version_info(pattern_groups: PatternGroups) -> VersionInfo: @@ -289,8 +289,8 @@ def parse_version_info(version_str: str, pattern: str = "{pycalver}") -> Version f"for pattern '{pattern}'/'{pattern_tup.regexp.pattern}'" ) raise PatternError(err_msg) - - return _parse_version_info(match.groupdict()) + else: + return _parse_version_info(match.groupdict()) def is_valid(version_str: str, pattern: str = "{pycalver}") -> bool: