MCPcopy Index your code
hub / github.com/numpy/numpy / Version

Class Version

numpy/_utils/_pep440.py:284–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282
283
284class Version(_BaseVersion):
285
286 _regex = re.compile(
287 r"^\s*" + VERSION_PATTERN + r"\s*$",
288 re.VERBOSE | re.IGNORECASE,
289 )
290
291 def __init__(self, version):
292 # Validate the version and parse it into pieces
293 match = self._regex.search(version)
294 if not match:
295 raise InvalidVersion(f"Invalid version: '{version}'")
296
297 # Store the parsed out pieces of the version
298 self._version = _Version(
299 epoch=int(match.group("epoch")) if match.group("epoch") else 0,
300 release=tuple(int(i) for i in match.group("release").split(".")),
301 pre=_parse_letter_version(
302 match.group("pre_l"),
303 match.group("pre_n"),
304 ),
305 post=_parse_letter_version(
306 match.group("post_l"),
307 match.group("post_n1") or match.group("post_n2"),
308 ),
309 dev=_parse_letter_version(
310 match.group("dev_l"),
311 match.group("dev_n"),
312 ),
313 local=_parse_local_version(match.group("local")),
314 )
315
316 # Generate a key which will be used for sorting
317 self._key = _cmpkey(
318 self._version.epoch,
319 self._version.release,
320 self._version.pre,
321 self._version.post,
322 self._version.dev,
323 self._version.local,
324 )
325
326 def __repr__(self):
327 return f"<Version({str(self)!r})>"
328
329 def __str__(self):
330 parts = []
331
332 # Epoch
333 if self._version.epoch != 0:
334 parts.append(f"{self._version.epoch}!")
335
336 # Release segment
337 parts.append(".".join(str(x) for x in self._version.release))
338
339 # Pre-release
340 if self._version.pre is not None:
341 parts.append("".join(str(x) for x in self._version.pre))

Callers 1

parseFunction · 0.85

Calls 1

compileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…