Skip to content

Commit

Permalink
Simplified types
Browse files Browse the repository at this point in the history
* Remove unused Int_or_Str type
* Reuse String in SpecComparable
  • Loading branch information
tomschr committed Jul 24, 2023
1 parent fe2bdc9 commit 3f20784
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/semver/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from .version import Version
from ._types import String

Int_or_Str = Union[int, str]


class InvalidSpecifier(ValueError):
"""
Expand All @@ -31,7 +29,7 @@ class InvalidSpecifier(ValueError):


# These types are required here because of circular imports
SpecComparable = Union[Version, str, bytes, dict, tuple, list]
SpecComparable = Union[Version, String, dict, tuple, list]
SpecComparator = Callable[["Spec", SpecComparable], bool]


Expand Down Expand Up @@ -273,6 +271,8 @@ def spec(self) -> str:
'>=1.2.3'
>>> Spec(">=1.2.x").spec
'>=1.2.*'
>>> Spec("2.1.4").spec
'==2.1.4'
"""
return f"{self._operator}{self._realversion}"

Expand Down
4 changes: 2 additions & 2 deletions src/semver/versionregex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Defines basic regex constants."""

import re
from typing import ClassVar, Pattern
from typing import ClassVar, Pattern, Tuple


class VersionRegex:
Expand All @@ -18,7 +18,7 @@ class VersionRegex:
_LAST_NUMBER: ClassVar[Pattern[str]] = re.compile(r"(?:[^\d]*(\d+)[^\d]*)+")

#: The names of the different parts of a version
NAMES = ("major", "minor", "patch", "prerelease", "build")
NAMES: ClassVar[Tuple[str, ...]] = ("major", "minor", "patch", "prerelease", "build")

#: The regex of the major part of a version:
MAJOR: ClassVar[str] = rf"(?P<major>{_RE_NUMBER})"
Expand Down

0 comments on commit 3f20784

Please sign in to comment.