requirements-detector 1.3.1__py3-none-any.whl → 1.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- requirements_detector/detect.py +42 -11
- requirements_detector/poetry_semver/__init__.py +2 -2
- requirements_detector/poetry_semver/version.py +38 -38
- requirements_detector/poetry_semver/version_constraint.py +8 -8
- requirements_detector/poetry_semver/version_range.py +14 -14
- requirements_detector/poetry_semver/version_union.py +12 -9
- requirements_detector/py.typed +0 -0
- {requirements_detector-1.3.1.dist-info → requirements_detector-1.3.2.dist-info}/METADATA +2 -2
- {requirements_detector-1.3.1.dist-info → requirements_detector-1.3.2.dist-info}/RECORD +12 -11
- {requirements_detector-1.3.1.dist-info → requirements_detector-1.3.2.dist-info}/LICENSE +0 -0
- {requirements_detector-1.3.1.dist-info → requirements_detector-1.3.2.dist-info}/WHEEL +0 -0
- {requirements_detector-1.3.1.dist-info → requirements_detector-1.3.2.dist-info}/entry_points.txt +0 -0
requirements_detector/detect.py
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import sys
|
|
2
3
|
from pathlib import Path
|
|
3
|
-
from typing import List, Union
|
|
4
|
+
from typing import List, Optional, Union
|
|
4
5
|
|
|
5
6
|
import toml
|
|
6
7
|
|
|
7
8
|
from .exceptions import CouldNotParseRequirements, RequirementsNotFound
|
|
8
9
|
from .handle_setup import from_setup_py
|
|
9
10
|
from .poetry_semver import parse_constraint
|
|
11
|
+
from .poetry_semver.version_constraint import VersionConstraint
|
|
10
12
|
from .requirement import DetectedRequirement
|
|
11
13
|
|
|
14
|
+
_USE_TOMLLIB = sys.version_info.major > 3 or sys.version_info.minor >= 11
|
|
15
|
+
if _USE_TOMLLIB:
|
|
16
|
+
import tomllib
|
|
17
|
+
else:
|
|
18
|
+
import toml
|
|
19
|
+
|
|
12
20
|
__all__ = [
|
|
13
21
|
"find_requirements",
|
|
14
22
|
"from_requirements_txt",
|
|
@@ -102,13 +110,36 @@ def find_requirements(path: P) -> List[DetectedRequirement]:
|
|
|
102
110
|
raise RequirementsNotFound
|
|
103
111
|
|
|
104
112
|
|
|
113
|
+
def _version_from_spec(spec: Union[list, dict, str]) -> Optional[VersionConstraint]:
|
|
114
|
+
if isinstance(spec, list):
|
|
115
|
+
constraint = None
|
|
116
|
+
for new_constraint in [_version_from_spec(s) for s in spec]:
|
|
117
|
+
if constraint is None:
|
|
118
|
+
constraint = new_constraint
|
|
119
|
+
elif new_constraint is not None:
|
|
120
|
+
constraint = constraint.union(new_constraint)
|
|
121
|
+
return constraint
|
|
122
|
+
|
|
123
|
+
if isinstance(spec, dict):
|
|
124
|
+
if "version" in spec:
|
|
125
|
+
spec = spec["version"]
|
|
126
|
+
else:
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
return parse_constraint(spec)
|
|
130
|
+
|
|
131
|
+
|
|
105
132
|
def from_pyproject_toml(toml_file: P) -> List[DetectedRequirement]:
|
|
106
133
|
requirements = []
|
|
107
134
|
|
|
108
135
|
if isinstance(toml_file, str):
|
|
109
136
|
toml_file = Path(toml_file)
|
|
110
137
|
|
|
111
|
-
|
|
138
|
+
if _USE_TOMLLIB:
|
|
139
|
+
with open(toml_file, "rb") as toml_file_open:
|
|
140
|
+
parsed = tomllib.load(toml_file_open)
|
|
141
|
+
else:
|
|
142
|
+
parsed = toml.load(toml_file)
|
|
112
143
|
poetry_section = parsed.get("tool", {}).get("poetry", {})
|
|
113
144
|
dependencies = poetry_section.get("dependencies", {})
|
|
114
145
|
dependencies.update(poetry_section.get("dev-dependencies", {}))
|
|
@@ -116,15 +147,15 @@ def from_pyproject_toml(toml_file: P) -> List[DetectedRequirement]:
|
|
|
116
147
|
for name, spec in dependencies.items():
|
|
117
148
|
if name.lower() == "python":
|
|
118
149
|
continue
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
parsed_spec = str(
|
|
150
|
+
|
|
151
|
+
parsed_spec_obj = _version_from_spec(spec)
|
|
152
|
+
if parsed_spec_obj is None and isinstance(spec, dict) and "version" not in spec:
|
|
153
|
+
req = DetectedRequirement.parse(f"{name}", toml_file)
|
|
154
|
+
if req is not None:
|
|
155
|
+
requirements.append(req)
|
|
156
|
+
continue
|
|
157
|
+
assert parsed_spec_obj is not None
|
|
158
|
+
parsed_spec = str(parsed_spec_obj)
|
|
128
159
|
if "," not in parsed_spec and "<" not in parsed_spec and ">" not in parsed_spec and "=" not in parsed_spec:
|
|
129
160
|
parsed_spec = f"=={parsed_spec}"
|
|
130
161
|
|
|
@@ -16,7 +16,7 @@ from .version_union import VersionUnion
|
|
|
16
16
|
__version__ = "0.1.0"
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def parse_constraint(constraints
|
|
19
|
+
def parse_constraint(constraints: str) -> VersionConstraint:
|
|
20
20
|
if constraints == "*":
|
|
21
21
|
return VersionRange()
|
|
22
22
|
|
|
@@ -47,7 +47,7 @@ def parse_constraint(constraints): # type: (str) -> VersionConstraint
|
|
|
47
47
|
return VersionUnion.of(*or_groups)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def parse_single_constraint(constraint
|
|
50
|
+
def parse_single_constraint(constraint: str) -> VersionConstraint:
|
|
51
51
|
m = re.match(r"(?i)^v?[xX*](\.[xX*])*$", constraint)
|
|
52
52
|
if m:
|
|
53
53
|
return VersionRange()
|
|
@@ -16,15 +16,15 @@ class Version(VersionRange):
|
|
|
16
16
|
|
|
17
17
|
def __init__(
|
|
18
18
|
self,
|
|
19
|
-
major
|
|
20
|
-
minor
|
|
21
|
-
patch
|
|
22
|
-
rest
|
|
23
|
-
pre
|
|
24
|
-
build
|
|
25
|
-
text
|
|
26
|
-
precision
|
|
27
|
-
)
|
|
19
|
+
major: int,
|
|
20
|
+
minor: Optional[int] = None,
|
|
21
|
+
patch: Optional[int] = None,
|
|
22
|
+
rest: Optional[int] = None,
|
|
23
|
+
pre: Optional[str] = None,
|
|
24
|
+
build: Optional[str] = None,
|
|
25
|
+
text: Optional[str] = None,
|
|
26
|
+
precision: Optional[int] = None,
|
|
27
|
+
) -> None:
|
|
28
28
|
self._major = int(major)
|
|
29
29
|
self._precision = None
|
|
30
30
|
if precision is None:
|
|
@@ -92,27 +92,27 @@ class Version(VersionRange):
|
|
|
92
92
|
self._build = self._split_parts(build)
|
|
93
93
|
|
|
94
94
|
@property
|
|
95
|
-
def major(self)
|
|
95
|
+
def major(self) -> int:
|
|
96
96
|
return self._major
|
|
97
97
|
|
|
98
98
|
@property
|
|
99
|
-
def minor(self)
|
|
99
|
+
def minor(self) -> int:
|
|
100
100
|
return self._minor
|
|
101
101
|
|
|
102
102
|
@property
|
|
103
|
-
def patch(self)
|
|
103
|
+
def patch(self) -> int:
|
|
104
104
|
return self._patch
|
|
105
105
|
|
|
106
106
|
@property
|
|
107
|
-
def rest(self)
|
|
107
|
+
def rest(self) -> int:
|
|
108
108
|
return self._rest
|
|
109
109
|
|
|
110
110
|
@property
|
|
111
|
-
def prerelease(self)
|
|
111
|
+
def prerelease(self) -> List[str]:
|
|
112
112
|
return self._prerelease
|
|
113
113
|
|
|
114
114
|
@property
|
|
115
|
-
def build(self)
|
|
115
|
+
def build(self) -> List[str]:
|
|
116
116
|
return self._build
|
|
117
117
|
|
|
118
118
|
@property
|
|
@@ -120,7 +120,7 @@ class Version(VersionRange):
|
|
|
120
120
|
return self._text
|
|
121
121
|
|
|
122
122
|
@property
|
|
123
|
-
def precision(self)
|
|
123
|
+
def precision(self) -> int:
|
|
124
124
|
return self._precision
|
|
125
125
|
|
|
126
126
|
@property
|
|
@@ -131,28 +131,28 @@ class Version(VersionRange):
|
|
|
131
131
|
return self.next_patch
|
|
132
132
|
|
|
133
133
|
@property
|
|
134
|
-
def next_major(self)
|
|
134
|
+
def next_major(self) -> "Version":
|
|
135
135
|
if self.is_prerelease() and self.minor == 0 and self.patch == 0:
|
|
136
136
|
return Version(self.major, self.minor, self.patch)
|
|
137
137
|
|
|
138
138
|
return self._increment_major()
|
|
139
139
|
|
|
140
140
|
@property
|
|
141
|
-
def next_minor(self)
|
|
141
|
+
def next_minor(self) -> "Version":
|
|
142
142
|
if self.is_prerelease() and self.patch == 0:
|
|
143
143
|
return Version(self.major, self.minor, self.patch)
|
|
144
144
|
|
|
145
145
|
return self._increment_minor()
|
|
146
146
|
|
|
147
147
|
@property
|
|
148
|
-
def next_patch(self)
|
|
148
|
+
def next_patch(self) -> "Version":
|
|
149
149
|
if self.is_prerelease():
|
|
150
150
|
return Version(self.major, self.minor, self.patch)
|
|
151
151
|
|
|
152
152
|
return self._increment_patch()
|
|
153
153
|
|
|
154
154
|
@property
|
|
155
|
-
def next_breaking(self)
|
|
155
|
+
def next_breaking(self) -> "Version":
|
|
156
156
|
if self.major == 0:
|
|
157
157
|
if self.minor != 0:
|
|
158
158
|
return self._increment_minor()
|
|
@@ -167,7 +167,7 @@ class Version(VersionRange):
|
|
|
167
167
|
return self._increment_major()
|
|
168
168
|
|
|
169
169
|
@property
|
|
170
|
-
def first_prerelease(self)
|
|
170
|
+
def first_prerelease(self) -> "Version":
|
|
171
171
|
return Version.parse("{}.{}.{}-alpha.0".format(self.major, self.minor, self.patch))
|
|
172
172
|
|
|
173
173
|
@property
|
|
@@ -191,7 +191,7 @@ class Version(VersionRange):
|
|
|
191
191
|
return True
|
|
192
192
|
|
|
193
193
|
@classmethod
|
|
194
|
-
def parse(cls, text
|
|
194
|
+
def parse(cls, text: str) -> "Version":
|
|
195
195
|
try:
|
|
196
196
|
match = COMPLETE_VERSION.match(text)
|
|
197
197
|
except TypeError:
|
|
@@ -221,25 +221,25 @@ class Version(VersionRange):
|
|
|
221
221
|
def is_empty(self):
|
|
222
222
|
return False
|
|
223
223
|
|
|
224
|
-
def is_prerelease(self)
|
|
224
|
+
def is_prerelease(self) -> bool:
|
|
225
225
|
return len(self._prerelease) > 0
|
|
226
226
|
|
|
227
|
-
def allows(self, version
|
|
227
|
+
def allows(self, version: "Version") -> bool:
|
|
228
228
|
return self == version
|
|
229
229
|
|
|
230
|
-
def allows_all(self, other
|
|
230
|
+
def allows_all(self, other: VersionConstraint) -> bool:
|
|
231
231
|
return other.is_empty() or other == self
|
|
232
232
|
|
|
233
|
-
def allows_any(self, other
|
|
233
|
+
def allows_any(self, other: VersionConstraint) -> bool:
|
|
234
234
|
return other.allows(self)
|
|
235
235
|
|
|
236
|
-
def intersect(self, other
|
|
236
|
+
def intersect(self, other: VersionConstraint) -> VersionConstraint:
|
|
237
237
|
if other.allows(self):
|
|
238
238
|
return self
|
|
239
239
|
|
|
240
240
|
return EmptyConstraint()
|
|
241
241
|
|
|
242
|
-
def union(self, other
|
|
242
|
+
def union(self, other: VersionConstraint) -> VersionConstraint:
|
|
243
243
|
from .version_range import VersionRange
|
|
244
244
|
|
|
245
245
|
if other.allows(self):
|
|
@@ -264,25 +264,25 @@ class Version(VersionRange):
|
|
|
264
264
|
|
|
265
265
|
return VersionUnion.of(self, other)
|
|
266
266
|
|
|
267
|
-
def difference(self, other
|
|
267
|
+
def difference(self, other: VersionConstraint) -> VersionConstraint:
|
|
268
268
|
if other.allows(self):
|
|
269
269
|
return EmptyConstraint()
|
|
270
270
|
|
|
271
271
|
return self
|
|
272
272
|
|
|
273
|
-
def equals_without_prerelease(self, other
|
|
273
|
+
def equals_without_prerelease(self, other: "Version") -> bool:
|
|
274
274
|
return self.major == other.major and self.minor == other.minor and self.patch == other.patch
|
|
275
275
|
|
|
276
|
-
def _increment_major(self)
|
|
276
|
+
def _increment_major(self) -> "Version":
|
|
277
277
|
return Version(self.major + 1, 0, 0, precision=self._precision)
|
|
278
278
|
|
|
279
|
-
def _increment_minor(self)
|
|
279
|
+
def _increment_minor(self) -> "Version":
|
|
280
280
|
return Version(self.major, self.minor + 1, 0, precision=self._precision)
|
|
281
281
|
|
|
282
|
-
def _increment_patch(self)
|
|
282
|
+
def _increment_patch(self) -> "Version":
|
|
283
283
|
return Version(self.major, self.minor, self.patch + 1, precision=self._precision)
|
|
284
284
|
|
|
285
|
-
def _normalize_prerelease(self, pre
|
|
285
|
+
def _normalize_prerelease(self, pre: str) -> str:
|
|
286
286
|
if not pre:
|
|
287
287
|
return
|
|
288
288
|
|
|
@@ -307,7 +307,7 @@ class Version(VersionRange):
|
|
|
307
307
|
|
|
308
308
|
return "{}.{}".format(modifier, number)
|
|
309
309
|
|
|
310
|
-
def _normalize_build(self, build
|
|
310
|
+
def _normalize_build(self, build: str) -> str:
|
|
311
311
|
if not build:
|
|
312
312
|
return
|
|
313
313
|
|
|
@@ -319,7 +319,7 @@ class Version(VersionRange):
|
|
|
319
319
|
|
|
320
320
|
return build
|
|
321
321
|
|
|
322
|
-
def _split_parts(self, text
|
|
322
|
+
def _split_parts(self, text: str) -> List[Union[str, int]]:
|
|
323
323
|
parts = text.split(".")
|
|
324
324
|
|
|
325
325
|
for i, part in enumerate(parts):
|
|
@@ -389,7 +389,7 @@ class Version(VersionRange):
|
|
|
389
389
|
|
|
390
390
|
return 0
|
|
391
391
|
|
|
392
|
-
def _cmp_lists(self, a, b
|
|
392
|
+
def _cmp_lists(self, a: List, b: List) -> int:
|
|
393
393
|
for i in range(max(len(a), len(b))):
|
|
394
394
|
a_part = None
|
|
395
395
|
if i < len(a):
|
|
@@ -422,7 +422,7 @@ class Version(VersionRange):
|
|
|
422
422
|
|
|
423
423
|
return 0
|
|
424
424
|
|
|
425
|
-
def __eq__(self, other
|
|
425
|
+
def __eq__(self, other: "Version") -> bool:
|
|
426
426
|
if not isinstance(other, Version):
|
|
427
427
|
return NotImplemented
|
|
428
428
|
|
|
@@ -2,26 +2,26 @@ import semver
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class VersionConstraint:
|
|
5
|
-
def is_empty(self)
|
|
5
|
+
def is_empty(self) -> bool:
|
|
6
6
|
raise NotImplementedError()
|
|
7
7
|
|
|
8
|
-
def is_any(self)
|
|
8
|
+
def is_any(self) -> bool:
|
|
9
9
|
raise NotImplementedError()
|
|
10
10
|
|
|
11
|
-
def allows(self, version
|
|
11
|
+
def allows(self, version: semver.Version) -> bool:
|
|
12
12
|
raise NotImplementedError()
|
|
13
13
|
|
|
14
|
-
def allows_all(self, other
|
|
14
|
+
def allows_all(self, other: "VersionConstraint") -> bool:
|
|
15
15
|
raise NotImplementedError()
|
|
16
16
|
|
|
17
|
-
def allows_any(self, other
|
|
17
|
+
def allows_any(self, other: "VersionConstraint") -> bool:
|
|
18
18
|
raise NotImplementedError()
|
|
19
19
|
|
|
20
|
-
def intersect(self, other
|
|
20
|
+
def intersect(self, other: "VersionConstraint") -> "VersionConstraint":
|
|
21
21
|
raise NotImplementedError()
|
|
22
22
|
|
|
23
|
-
def union(self, other
|
|
23
|
+
def union(self, other: "VersionConstraint") -> "VersionConstraint":
|
|
24
24
|
raise NotImplementedError()
|
|
25
25
|
|
|
26
|
-
def difference(self, other
|
|
26
|
+
def difference(self, other: "VersionConstraint") -> "VersionConstraint":
|
|
27
27
|
raise NotImplementedError()
|
|
@@ -58,7 +58,7 @@ class VersionRange(VersionConstraint):
|
|
|
58
58
|
def is_any(self):
|
|
59
59
|
return self._min is None and self._max is None
|
|
60
60
|
|
|
61
|
-
def allows(self, other
|
|
61
|
+
def allows(self, other: semver.Version) -> bool:
|
|
62
62
|
if self._min is not None:
|
|
63
63
|
if other < self._min:
|
|
64
64
|
return False
|
|
@@ -75,7 +75,7 @@ class VersionRange(VersionConstraint):
|
|
|
75
75
|
|
|
76
76
|
return True
|
|
77
77
|
|
|
78
|
-
def allows_all(self, other
|
|
78
|
+
def allows_all(self, other: VersionConstraint) -> bool:
|
|
79
79
|
from .version import Version
|
|
80
80
|
|
|
81
81
|
if other.is_empty():
|
|
@@ -92,7 +92,7 @@ class VersionRange(VersionConstraint):
|
|
|
92
92
|
|
|
93
93
|
raise ValueError("Unknown VersionConstraint type {}.".format(other))
|
|
94
94
|
|
|
95
|
-
def allows_any(self, other
|
|
95
|
+
def allows_any(self, other: VersionConstraint) -> bool:
|
|
96
96
|
from .version import Version
|
|
97
97
|
|
|
98
98
|
if other.is_empty():
|
|
@@ -109,7 +109,7 @@ class VersionRange(VersionConstraint):
|
|
|
109
109
|
|
|
110
110
|
raise ValueError("Unknown VersionConstraint type {}.".format(other))
|
|
111
111
|
|
|
112
|
-
def intersect(self, other
|
|
112
|
+
def intersect(self, other: VersionConstraint) -> VersionConstraint:
|
|
113
113
|
from .version import Version
|
|
114
114
|
|
|
115
115
|
if other.is_empty():
|
|
@@ -162,7 +162,7 @@ class VersionRange(VersionConstraint):
|
|
|
162
162
|
# If we got here, there is an actual range.
|
|
163
163
|
return VersionRange(intersect_min, intersect_max, intersect_include_min, intersect_include_max)
|
|
164
164
|
|
|
165
|
-
def union(self, other
|
|
165
|
+
def union(self, other: VersionConstraint) -> VersionConstraint:
|
|
166
166
|
from .version import Version
|
|
167
167
|
|
|
168
168
|
if isinstance(other, Version):
|
|
@@ -210,7 +210,7 @@ class VersionRange(VersionConstraint):
|
|
|
210
210
|
|
|
211
211
|
return VersionUnion.of(self, other)
|
|
212
212
|
|
|
213
|
-
def difference(self, other
|
|
213
|
+
def difference(self, other: VersionConstraint) -> VersionConstraint:
|
|
214
214
|
from .version import Version
|
|
215
215
|
|
|
216
216
|
if other.is_empty():
|
|
@@ -265,7 +265,7 @@ class VersionRange(VersionConstraint):
|
|
|
265
265
|
|
|
266
266
|
return VersionUnion.of(before, after)
|
|
267
267
|
elif isinstance(other, VersionUnion):
|
|
268
|
-
ranges
|
|
268
|
+
ranges: List[VersionRange] = []
|
|
269
269
|
current = self
|
|
270
270
|
|
|
271
271
|
for range in other.ranges:
|
|
@@ -296,7 +296,7 @@ class VersionRange(VersionConstraint):
|
|
|
296
296
|
|
|
297
297
|
raise ValueError("Unknown VersionConstraint type {}.".format(other))
|
|
298
298
|
|
|
299
|
-
def allows_lower(self, other
|
|
299
|
+
def allows_lower(self, other: "VersionRange") -> bool:
|
|
300
300
|
if self.min is None:
|
|
301
301
|
return other.min is not None
|
|
302
302
|
|
|
@@ -311,7 +311,7 @@ class VersionRange(VersionConstraint):
|
|
|
311
311
|
|
|
312
312
|
return self.include_min and not other.include_min
|
|
313
313
|
|
|
314
|
-
def allows_higher(self, other
|
|
314
|
+
def allows_higher(self, other: "VersionRange") -> bool:
|
|
315
315
|
if self.max is None:
|
|
316
316
|
return other.max is not None
|
|
317
317
|
|
|
@@ -326,7 +326,7 @@ class VersionRange(VersionConstraint):
|
|
|
326
326
|
|
|
327
327
|
return self.include_max and not other.include_max
|
|
328
328
|
|
|
329
|
-
def is_strictly_lower(self, other
|
|
329
|
+
def is_strictly_lower(self, other: "VersionRange") -> bool:
|
|
330
330
|
if self.max is None or other.min is None:
|
|
331
331
|
return False
|
|
332
332
|
|
|
@@ -338,10 +338,10 @@ class VersionRange(VersionConstraint):
|
|
|
338
338
|
|
|
339
339
|
return not self.include_max or not other.include_min
|
|
340
340
|
|
|
341
|
-
def is_strictly_higher(self, other
|
|
341
|
+
def is_strictly_higher(self, other: "VersionRange") -> bool:
|
|
342
342
|
return other.is_strictly_lower(self)
|
|
343
343
|
|
|
344
|
-
def is_adjacent_to(self, other
|
|
344
|
+
def is_adjacent_to(self, other: "VersionRange") -> bool:
|
|
345
345
|
if self.max != other.min:
|
|
346
346
|
return False
|
|
347
347
|
|
|
@@ -370,7 +370,7 @@ class VersionRange(VersionConstraint):
|
|
|
370
370
|
def __ge__(self, other):
|
|
371
371
|
return self._cmp(other) >= 0
|
|
372
372
|
|
|
373
|
-
def _cmp(self, other
|
|
373
|
+
def _cmp(self, other: "VersionRange") -> int:
|
|
374
374
|
if self.min is None:
|
|
375
375
|
if other.min is None:
|
|
376
376
|
return self._compare_max(other)
|
|
@@ -388,7 +388,7 @@ class VersionRange(VersionConstraint):
|
|
|
388
388
|
|
|
389
389
|
return self._compare_max(other)
|
|
390
390
|
|
|
391
|
-
def _compare_max(self, other
|
|
391
|
+
def _compare_max(self, other: "VersionRange") -> int:
|
|
392
392
|
if self.max is None:
|
|
393
393
|
if other.max is None:
|
|
394
394
|
return 0
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import TYPE_CHECKING, List
|
|
2
2
|
|
|
3
3
|
import semver
|
|
4
4
|
|
|
5
5
|
from .empty_constraint import EmptyConstraint
|
|
6
6
|
from .version_constraint import VersionConstraint
|
|
7
7
|
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from .version_range import VersionRange
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
class VersionUnion(VersionConstraint):
|
|
10
13
|
"""
|
|
@@ -73,10 +76,10 @@ class VersionUnion(VersionConstraint):
|
|
|
73
76
|
def is_any(self):
|
|
74
77
|
return False
|
|
75
78
|
|
|
76
|
-
def allows(self, version
|
|
79
|
+
def allows(self, version: semver.Version) -> bool:
|
|
77
80
|
return any([constraint.allows(version) for constraint in self._ranges])
|
|
78
81
|
|
|
79
|
-
def allows_all(self, other
|
|
82
|
+
def allows_all(self, other: VersionConstraint) -> bool:
|
|
80
83
|
our_ranges = iter(self._ranges)
|
|
81
84
|
their_ranges = iter(self._ranges_for(other))
|
|
82
85
|
|
|
@@ -91,7 +94,7 @@ class VersionUnion(VersionConstraint):
|
|
|
91
94
|
|
|
92
95
|
return their_current_range is None
|
|
93
96
|
|
|
94
|
-
def allows_any(self, other
|
|
97
|
+
def allows_any(self, other: VersionConstraint) -> bool:
|
|
95
98
|
our_ranges = iter(self._ranges)
|
|
96
99
|
their_ranges = iter(self._ranges_for(other))
|
|
97
100
|
|
|
@@ -109,7 +112,7 @@ class VersionUnion(VersionConstraint):
|
|
|
109
112
|
|
|
110
113
|
return False
|
|
111
114
|
|
|
112
|
-
def intersect(self, other
|
|
115
|
+
def intersect(self, other: VersionConstraint) -> VersionConstraint:
|
|
113
116
|
our_ranges = iter(self._ranges)
|
|
114
117
|
their_ranges = iter(self._ranges_for(other))
|
|
115
118
|
new_ranges = []
|
|
@@ -130,10 +133,10 @@ class VersionUnion(VersionConstraint):
|
|
|
130
133
|
|
|
131
134
|
return VersionUnion.of(*new_ranges)
|
|
132
135
|
|
|
133
|
-
def union(self, other
|
|
136
|
+
def union(self, other: VersionConstraint) -> VersionConstraint:
|
|
134
137
|
return VersionUnion.of(self, other)
|
|
135
138
|
|
|
136
|
-
def difference(self, other
|
|
139
|
+
def difference(self, other: VersionConstraint) -> VersionConstraint:
|
|
137
140
|
our_ranges = iter(self._ranges)
|
|
138
141
|
their_ranges = iter(self._ranges_for(other))
|
|
139
142
|
new_ranges = []
|
|
@@ -213,7 +216,7 @@ class VersionUnion(VersionConstraint):
|
|
|
213
216
|
|
|
214
217
|
return VersionUnion.of(*new_ranges)
|
|
215
218
|
|
|
216
|
-
def _ranges_for(self, constraint
|
|
219
|
+
def _ranges_for(self, constraint: VersionConstraint) -> List["VersionRange"]:
|
|
217
220
|
from .version_range import VersionRange
|
|
218
221
|
|
|
219
222
|
if constraint.is_empty():
|
|
@@ -227,7 +230,7 @@ class VersionUnion(VersionConstraint):
|
|
|
227
230
|
|
|
228
231
|
raise ValueError("Unknown VersionConstraint type {}".format(constraint))
|
|
229
232
|
|
|
230
|
-
def _excludes_single_version(self)
|
|
233
|
+
def _excludes_single_version(self) -> bool:
|
|
231
234
|
from .version import Version
|
|
232
235
|
from .version_range import VersionRange
|
|
233
236
|
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: requirements-detector
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Python tool to find and list requirements of a Python project
|
|
5
5
|
Home-page: https://github.com/landscapeio/requirements-detector
|
|
6
6
|
License: MIT
|
|
@@ -23,7 +23,7 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
23
23
|
Requires-Dist: astroid (>=3.0,<4.0)
|
|
24
24
|
Requires-Dist: packaging (>=21.3)
|
|
25
25
|
Requires-Dist: semver (>=3.0.0,<4.0.0)
|
|
26
|
-
Requires-Dist: toml (>=0.10.2,<0.11.0)
|
|
26
|
+
Requires-Dist: toml (>=0.10.2,<0.11.0) ; python_version < "3.11"
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
|
|
29
29
|
# Requirements Detector
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
requirements_detector/__init__.py,sha256=XbBRnMPYhG2Eq2IhZQAzOA9d-9OTYMXJwRiaZhLFAEY,269
|
|
2
2
|
requirements_detector/__main__.py,sha256=U6nHQrMwd11auXYgQsT0wqqqKyyGKXxHZ_SDaaOi878,59
|
|
3
|
-
requirements_detector/detect.py,sha256=
|
|
3
|
+
requirements_detector/detect.py,sha256=E9jvDPxifmbf0VWhuzVZVkpx990ogrYmIqXLmBtDPxw,6867
|
|
4
4
|
requirements_detector/exceptions.py,sha256=bTy7-ZvAXt-nucXKnaYIBxa5FngtFpD95FXswejc7Wk,103
|
|
5
5
|
requirements_detector/formatters.py,sha256=zcxR2n2Tp8z3DHkpokbjHorNqei5LZ9hprWZK0ZBVik,340
|
|
6
6
|
requirements_detector/handle_setup.py,sha256=K-tnZP9ioKO-zgVsDRaI9aBBZpMtQKLPkXyFWotohEk,3947
|
|
7
7
|
requirements_detector/poetry_semver/README.md,sha256=lU6DxV4Qk1qv_KIgOW1uEahx6PWDNhnIziF2izA49-k,261
|
|
8
|
-
requirements_detector/poetry_semver/__init__.py,sha256=
|
|
8
|
+
requirements_detector/poetry_semver/__init__.py,sha256=nSyskyy880xTIhbvvwBuUg0Jmu6DepC27kTWFJO49Hk,4661
|
|
9
9
|
requirements_detector/poetry_semver/empty_constraint.py,sha256=U_a8Obi0shKP4KoLDbXTGWzwha3J4HKwqEKWTNiLfuo,562
|
|
10
10
|
requirements_detector/poetry_semver/exceptions.py,sha256=M16rxsgcZfZUUiys8fKBPicD0AqCdP3kLlekm3_WkmA,46
|
|
11
11
|
requirements_detector/poetry_semver/patterns.py,sha256=ejPriORCt-gB5MoUh8aNo5bcBV5ZTM8joWXJ5WUwlEQ,741
|
|
12
|
-
requirements_detector/poetry_semver/version.py,sha256=
|
|
13
|
-
requirements_detector/poetry_semver/version_constraint.py,sha256=
|
|
14
|
-
requirements_detector/poetry_semver/version_range.py,sha256=
|
|
15
|
-
requirements_detector/poetry_semver/version_union.py,sha256=
|
|
12
|
+
requirements_detector/poetry_semver/version.py,sha256=DzSr4OqxSPY0TgKR2PqNCjQRt_vdg0VtkYnuSuBSXyQ,11829
|
|
13
|
+
requirements_detector/poetry_semver/version_constraint.py,sha256=Vp5KW27IuXroKwcgBT7PZYxLaohoeCY3XMG4h0xvmK0,802
|
|
14
|
+
requirements_detector/poetry_semver/version_range.py,sha256=FN05z4gituRsah1AxDogx2w-KRQPkRV03jIXTSqCpmI,13055
|
|
15
|
+
requirements_detector/poetry_semver/version_union.py,sha256=qBqU0ocnHkLVKxKYZXz_MwODVzyRbuIcD2nN1LFUqL4,7922
|
|
16
|
+
requirements_detector/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
17
|
requirements_detector/requirement.py,sha256=XuKspLsLY_sZOVKupXSjGFMxV1u3NHaTgjb-kRXbzFg,5548
|
|
17
18
|
requirements_detector/run.py,sha256=8AjUalMAmCgK4HAsswSoxVG4N_uhYrvGMhZnfQUf8X8,861
|
|
18
|
-
requirements_detector-1.3.
|
|
19
|
-
requirements_detector-1.3.
|
|
20
|
-
requirements_detector-1.3.
|
|
21
|
-
requirements_detector-1.3.
|
|
22
|
-
requirements_detector-1.3.
|
|
19
|
+
requirements_detector-1.3.2.dist-info/LICENSE,sha256=548oOCrCNqQty8Fsqqry522lXdxnBTqLyzqr38ct-cw,1040
|
|
20
|
+
requirements_detector-1.3.2.dist-info/METADATA,sha256=5QbwMaMSgTDIzgIHcS3afg2Twqam64KiokLHopbOhu4,3713
|
|
21
|
+
requirements_detector-1.3.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
22
|
+
requirements_detector-1.3.2.dist-info/entry_points.txt,sha256=c1Pyo5EK49kT1g7Wac3vwl0bVs0QBZeQ8Zia1WVL1do,69
|
|
23
|
+
requirements_detector-1.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{requirements_detector-1.3.1.dist-info → requirements_detector-1.3.2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|