Skip to content

Commit bb7a7fd

Browse files
committed
Fix code formatting
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 7757ea0 commit bb7a7fd

2 files changed

Lines changed: 27 additions & 39 deletions

File tree

src/univers/version_range.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ def __contains__(self, version):
223223

224224
def __eq__(self, other):
225225
return (
226-
self.scheme == other.scheme
227-
and self.version_class == other.version_class
228-
and self.constraints == other.constraints
226+
self.scheme == other.scheme
227+
and self.version_class == other.version_class
228+
and self.constraints == other.constraints
229229
)
230230

231231

@@ -355,9 +355,9 @@ def from_native(cls, string):
355355
)
356356
else:
357357
if (
358-
constraint.endswith(".x")
359-
or constraint.startswith("~")
360-
or constraint.startswith("^")
358+
constraint.endswith(".x")
359+
or constraint.startswith("~")
360+
or constraint.startswith("^")
361361
):
362362
constraints.extend(
363363
get_npm_version_constraints_from_semver_npm_spec(
@@ -949,7 +949,8 @@ def from_native(cls, string):
949949
if "*" in version:
950950
if "*" in version and not version.endswith("*") or constraints:
951951
raise InvalidVersionRange(
952-
f"Unsupported star in the middle of a version: it should be a trailing star only: {string}")
952+
f"Unsupported star in the middle of a version: it should be a trailing star only: {string}"
953+
)
953954

954955
if version.endswith(".*.*"):
955956
version = version.replace(".*.*", ".*")
@@ -999,7 +1000,9 @@ def from_native(cls, string):
9991000

10001001
else:
10011002
comparator, version = VersionConstraint.split(version)
1002-
constraint = VersionConstraint(comparator=comparator, version=cls.version_class(version))
1003+
constraint = VersionConstraint(
1004+
comparator=comparator, version=cls.version_class(version)
1005+
)
10031006
constraints.append(constraint)
10041007

10051008
return cls(constraints=tuple(constraints))

tests/test_cargo_version_range.py

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,95 +11,80 @@
1111
# tilde
1212
["~1.2.3", [[">=", "1.2.3"], ["<", "1.3.0"]], ["1.2.4"], ["2.0.1"]],
1313
["~1.2", [[">=", "1.2.0"], ["<", "1.3.0"]], ["1.2.5"], ["1.3.1"]],
14-
["~1", [[">=", "1.0.0"], ["<", "2.0.0"]], ["1.3.0", "1.8.1"], ["2.1.0", "2.2"]], # tilde increment the major
14+
[
15+
"~1",
16+
[[">=", "1.0.0"], ["<", "2.0.0"]],
17+
["1.3.0", "1.8.1"],
18+
["2.1.0", "2.2"],
19+
], # tilde increment the major
1520
# wildcard
1621
["*", [[">=", "0.0.0"]], ["1.0.0", "2.0.0"], []],
1722
["1.*", [], ["1.0.0"], ["2"]],
1823
["1.2.*", [[">=", "1.2.0"], ["<", "1.3.0"]], ["1.2", "1.2.1"], ["2.1.0", "2.2"]],
19-
2024
# https://github.com/dtolnay/semver/blob/master/tests/test_version_req.rs :
21-
2225
# test_basic
2326
# ["^1.0.0", [[]], ["1.0.0", "1.1.0", "1.0.1"], ["0.9.9", "0.10.0", "0.1.0", "1.0.0-pre", "1.0.1-pre"]],
24-
2527
# test_exact
2628
["=1.0.0", [["=", "1.0.0"]], ["1.0.0"], ["1.0.1", "0.9.9", "0.10.0", "0.1.0", "1.0.0-pre"]],
2729
["=0.9.0", [["=", "0.9.0"]], ["0.9.0"], ["0.9.1", "1.9.0", "0.0.9", "0.9.0-pre"]],
2830
["=0.0.2", [["=", "0.0.2"]], ["0.0.2"], ["0.0.1", "0.0.3", "0.0.2-pre"]],
29-
["=0.1.0-beta2.a", [["=", "0.1.0-beta2.a"]], ["0.1.0-beta2.a"], ["0.9.1", "0.1.0", "0.1.1-beta2.a", "0.1.0-beta2"]],
31+
[
32+
"=0.1.0-beta2.a",
33+
[["=", "0.1.0-beta2.a"]],
34+
["0.1.0-beta2.a"],
35+
["0.9.1", "0.1.0", "0.1.1-beta2.a", "0.1.0-beta2"],
36+
],
3037
# https://github.com/dtolnay/semver/blob/master/tests/test_version_req.rs#L73
3138
# ["=0.1.0+meta", [["=", "0.1.0+meta"]], ["0.1.0", "0.1.0+meta", "0.1.0+any"], []],
32-
3339
# test_greater_than
3440
# [">= 1.0.0", [[]], ["1.0.0", "2.0.0"], ["0.1.0", "0.0.1", "1.0.0-pre", "2.0.0-pre"]],
3541
# [">= 2.1.0-alpha2", [[]], ["2.1.0-alpha2", "2.1.0-alpha3", "2.1.0", "3.0.0"], ["2.0.0", "2.1.0-alpha1", "2.0.0-alpha2", "3.0.0-alpha2"]],
36-
3742
# test_less_than
3843
# ["<1.0.0", [[]], ["0.1.0", "0.0.1"], ["1.0.0", "1.0.0-beta", "1.0.1", "0.9.9-alpha"]],
3944
# ["<= 2.1.0-alpha2", [[]], ["2.1.0-alpha2", "2.1.0-alpha1", "2.0.0", "1.0.0"], ["2.1.0", "2.2.0-alpha1", "2.0.0-alpha2", "1.0.0-alpha2"]],
4045
# [">1.0.0-alpha, <1.0.0", [[">", "2.1.0-alpha2"], ["<", "1.0.0"]], ["1.0.0-beta"], []],
4146
# [">1.0.0-alpha, <1.0", [[">", "1.0.0-alpha"], ["<", "1.0"]]], ["1.0.0-beta"], []],
4247
[">1.0.0-alpha, <1", [[">", "1.0.0-alpha"], ["<", "1"]], ["1.0.0-beta"], []],
43-
4448
# test_multiple
4549
["> 0.0.9, <= 2.5.3", [[]], ["0.0.10", "1.0.0", "2.5.3"], ["0.0.8", "2.5.4"]],
4650
# ["^0.3.0, ^0.4.0", [[]], [], ["0.0.8", "0.3.0", "0.4.0"]],
4751
# ["<=0.2.0, >=0.5.0", [[]], [], ["0.0.8", "0.3.0", "0.5.1"]],
4852
# ["^0.1.0, ^0.1.4, ^0.1.6", [[]], ["0.1.6", "0.1.9"], ["0.1.0", "0.1.4", "0.2.0"]],
4953
# [">=0.5.1-alpha3, <0.6", [[[">", "0.5.1-alpha3"], ["=", "0.5.1-alpha3"], ["<", "0.6"]]], ["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"], ["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre"]],
50-
5154
# test_tilde
5255
["~1", [[]], ["1.0.0", "1.0.1", "1.1.1"], ["0.9.1", "2.9.0", "0.0.9"]],
5356
["~1.2", [[]], ["1.2.0", "1.2.1"], ["1.1.1", "1.3.0", "0.0.9"]],
5457
["~1.2.2", [[]], ["1.2.2", "1.2.4"], ["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]],
5558
# ["~1.2.3-beta.2", [[]], ["1.2.3", "1.2.4", "1.2.3-beta.2", "1.2.3-beta.4"],
5659
# ["1.3.3", "1.1.4", "1.2.3-beta.1", "1.2.4-beta.2"]],
57-
5860
# test_caret
5961
# ["^1", [[]], ["1.1.2", "1.1.0", "1.2.1", "1.0.1"],
6062
# ["0.9.1", "2.9.0", "0.1.4", "1.0.0-beta1", "0.1.0-alpha", "1.0.1-pre"]],
61-
62-
["^1.1", [[]], ["1.1.2", "1.1.0", "1.2.1"],
63-
["0.9.1", "2.9.0", "1.0.1", "0.1.4"]],
64-
63+
["^1.1", [[]], ["1.1.2", "1.1.0", "1.2.1"], ["0.9.1", "2.9.0", "1.0.1", "0.1.4"]],
6564
# ["^1.1.2", [[]], ["1.1.2", "1.1.4", "1.2.1"],
6665
# ["0.9.1", "2.9.0", "1.1.1", "0.0.1", "1.1.2-alpha1", "1.1.3-alpha1", "2.9.0-alpha1"]],
67-
6866
# ["^0.1.2", [[]], ["0.1.2", "0.1.4"],
6967
# ["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.2-beta", "0.1.3-alpha", "0.2.0-pre"]],
70-
7168
# ["^0.5.1-alpha3", [[]], ["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5", ],
7269
# ["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre", "0.6.0"]],
73-
74-
["^0.0.2", [[]], ["0.0.2"],
75-
["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]],
76-
70+
["^0.0.2", [[]], ["0.0.2"], ["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]],
7771
# ["^0.0", [[]], ["0.0.2", "0.0.0"],
7872
# ["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]],
79-
80-
["^0", [[]], ["0.9.1", "0.0.2", "0.0.0"],
81-
["2.9.0", "1.1.1"]],
82-
73+
["^0", [[]], ["0.9.1", "0.0.2", "0.0.0"], ["2.9.0", "1.1.1"]],
8374
# ["^1.4.2-beta.5", [[]], ["1.4.2", "1.4.3", "1.4.2-beta.5", "1.4.2-beta.6", "1.4.2-c"],
8475
# ["0.9.9", "2.0.0", "1.4.2-alpha", "1.4.2-beta.4", "1.4.3-beta.5"]],
85-
8676
# test_wildcard
8777
# https://github.com/dtolnay/semver/blob/master/tests/test_version_req.rs#L272
8878
# ["*", [[]], ["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"],
8979
# ["1.0.0-pre"]],
90-
9180
# ["1.*", [[]], ["1.2.0", "1.2.1", "1.1.1", "1.3.0"],
9281
# ["0.0.9", "1.2.0-pre"]],
93-
9482
# ["1.2.*", [[]], ["1.2.0", "1.2.2", "1.2.4"],
9583
# ["1.9.0", "1.0.9", "2.0.1", "0.1.3", "1.2.2-pre"]],
96-
9784
# test_pre
9885
# ["=2.1.1-really.0", [[]], ["2.1.1-really.0"], []]
99-
10086
# test_cargo3202
101-
["0.*.*", [[]], ["0.5.0"], []]
102-
87+
["0.*.*", [[]], ["0.5.0"], []],
10388
]
10489

10590

0 commit comments

Comments
 (0)