Skip to content

Commit 5d9f68e

Browse files
committed
Reformatted with black
1 parent 948539f commit 5d9f68e

File tree

4 files changed

+28
-39
lines changed

4 files changed

+28
-39
lines changed

src/semver/spec.py

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def wrapper(self: "Spec", other: SpecComparable) -> bool:
4444
if not isinstance(other, comparable_types):
4545
return NotImplemented
4646
# For compatible types, convert them to Version instance:
47-
if isinstance(other, String.__args__): # type: ignore
47+
if isinstance(other, String.__args__): # type: ignore
4848
other = Version.parse(cast(String, other))
4949
if isinstance(other, dict):
5050
other = Version(**other)
@@ -129,8 +129,7 @@ class however, only ``*`` is used regardless what you used before.
129129
"""
130130

131131
_regex = re.compile(
132-
rf"{_operator_regex_str}?\s*{_version_regex_str}",
133-
re.VERBOSE | re.IGNORECASE
132+
rf"{_operator_regex_str}?\s*{_version_regex_str}", re.VERBOSE | re.IGNORECASE
134133
)
135134

136135
_regex_version_any = re.compile(_version_any, re.VERBOSE | re.IGNORECASE)
@@ -200,7 +199,7 @@ def __init__(self, spec: Union[str, bytes]) -> None:
200199
]
201200

202201
# This is the special case for 1 -> 1.0.0
203-
if (minor is None and patch is None):
202+
if minor is None and patch is None:
204203
self.real_version_tuple[1:3] = (0, 0)
205204
elif (minor not in placeholders) and (patch is None):
206205
self.real_version_tuple[2] = 0
@@ -309,61 +308,55 @@ def __eq__(self, other: SpecComparable) -> bool: # type: ignore
309308
"""self == other."""
310309
# Find the position of the first "*"
311310
index = self.__get_index()
312-
version = tuple([
313-
int(cast(int, item))
314-
for item in self.real_version_tuple[:index]
315-
])
311+
version = tuple(
312+
[int(cast(int, item)) for item in self.real_version_tuple[:index]]
313+
)
316314

317315
return cast(Version, other[:index]) == version
318316

319317
@preparecomparison
320318
def __ne__(self, other: SpecComparable) -> bool: # type: ignore
321319
"""self != other."""
322320
index = self.__get_index()
323-
version = tuple([
324-
int(cast(int, item))
325-
for item in self.real_version_tuple[:index]
326-
])
321+
version = tuple(
322+
[int(cast(int, item)) for item in self.real_version_tuple[:index]]
323+
)
327324
return cast(Version, other[:index]) != version
328325

329326
@preparecomparison
330327
def __lt__(self, other: SpecComparable) -> bool:
331328
"""self < other."""
332329
index: Optional[int] = self.__get_index()
333-
version = tuple([
334-
int(cast(int, item))
335-
for item in self.real_version_tuple[:index]
336-
])
330+
version = tuple(
331+
[int(cast(int, item)) for item in self.real_version_tuple[:index]]
332+
)
337333
return cast(Version, other[:index]) < version
338334

339335
@preparecomparison
340336
def __gt__(self, other: SpecComparable) -> bool:
341337
"""self > other."""
342338
index = self.__get_index()
343-
version = tuple([
344-
int(cast(int, item))
345-
for item in self.real_version_tuple[:index]
346-
])
339+
version = tuple(
340+
[int(cast(int, item)) for item in self.real_version_tuple[:index]]
341+
)
347342
return cast(Version, other[:index]) > version
348343

349344
@preparecomparison
350345
def __le__(self, other: SpecComparable) -> bool:
351346
"""self <= other."""
352347
index = self.__get_index()
353-
version = tuple([
354-
int(cast(int, item))
355-
for item in self.real_version_tuple[:index]
356-
])
348+
version = tuple(
349+
[int(cast(int, item)) for item in self.real_version_tuple[:index]]
350+
)
357351
return cast(Version, other[:index]) <= version
358352

359353
@preparecomparison
360354
def __ge__(self, other: SpecComparable) -> bool:
361355
"""self >= other."""
362356
index = self.__get_index()
363-
version = tuple([
364-
int(cast(int, item))
365-
for item in self.real_version_tuple[:index]
366-
])
357+
version = tuple(
358+
[int(cast(int, item)) for item in self.real_version_tuple[:index]]
359+
)
367360
return cast(Version, other[:index]) >= version
368361

369362
# @preparecomparison
@@ -391,7 +384,8 @@ def _tilde(self, other: SpecComparable) -> bool:
391384
str(int(major) + 1 if length == 1 else major),
392385
str(int(minor) + 1 if length >= 2 else minor),
393386
"0",
394-
])
387+
]
388+
)
395389
# print("> tilde", length, u_version)
396390

397391
# Delegate it to other

src/semver/version.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ def __init__(
107107
build: Optional[Union[String, int]] = None,
108108
):
109109
# Build a dictionary of the arguments except prerelease and build
110-
version_parts = {
111-
"major": int(major),
112-
"minor": int(minor),
113-
"patch": int(patch)
114-
}
110+
version_parts = {"major": int(major), "minor": int(minor), "patch": int(patch)}
115111

116112
for name, value in version_parts.items():
117113
if value < 0:

src/semver/versionregex.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class VersionRegex:
99
1010
You don't instantiate this class.
1111
"""
12+
1213
#: a number
1314
_RE_NUMBER = r"0|[1-9]\d*"
1415

@@ -50,12 +51,12 @@ class VersionRegex:
5051

5152
#: Regex for a semver version
5253
_REGEX = re.compile(
53-
_REGEX_TEMPLATE.format(opt_patch='', opt_minor=''),
54+
_REGEX_TEMPLATE.format(opt_patch="", opt_minor=""),
5455
re.VERBOSE,
5556
)
5657

5758
#: Regex for a semver version that might be shorter
5859
_REGEX_OPTIONAL_MINOR_AND_PATCH = re.compile(
59-
_REGEX_TEMPLATE.format(opt_patch='?', opt_minor='?'),
60+
_REGEX_TEMPLATE.format(opt_patch="?", opt_minor="?"),
6061
re.VERBOSE,
6162
)

tests/conftest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@ def version() -> semver.Version:
2828
:rtype: Version
2929
"""
3030
return semver.Version(
31-
major=1, minor=2, patch=3,
32-
prerelease="alpha.1.2",
33-
build="build.11.e0f985a"
31+
major=1, minor=2, patch=3, prerelease="alpha.1.2", build="build.11.e0f985a"
3432
)

0 commit comments

Comments
 (0)