Skip to content

Commit 3f20784

Browse files
committed
Simplified types
* Remove unused Int_or_Str type * Reuse String in SpecComparable
1 parent fe2bdc9 commit 3f20784

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/semver/spec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from .version import Version
1616
from ._types import String
1717

18-
Int_or_Str = Union[int, str]
19-
2018

2119
class InvalidSpecifier(ValueError):
2220
"""
@@ -31,7 +29,7 @@ class InvalidSpecifier(ValueError):
3129

3230

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

3735

@@ -273,6 +271,8 @@ def spec(self) -> str:
273271
'>=1.2.3'
274272
>>> Spec(">=1.2.x").spec
275273
'>=1.2.*'
274+
>>> Spec("2.1.4").spec
275+
'==2.1.4'
276276
"""
277277
return f"{self._operator}{self._realversion}"
278278

src/semver/versionregex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Defines basic regex constants."""
22

33
import re
4-
from typing import ClassVar, Pattern
4+
from typing import ClassVar, Pattern, Tuple
55

66

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

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy