MCPcopy Create free account
hub / github.com/nodejs/node / _compare_compatible

Method _compare_compatible

tools/gyp/pylib/packaging/specifiers.py:376–395  ·  view source on GitHub ↗
(self, prospective: Version, spec: str)

Source from the content-addressed store, hash-verified

374 return operator_callable
375
376 def _compare_compatible(self, prospective: Version, spec: str) -> bool:
377
378 # Compatible releases have an equivalent combination of >= and ==. That
379 # is that ~=2.2 is equivalent to >=2.2,==2.*. This allows us to
380 # implement this in terms of the other specifiers instead of
381 # implementing it ourselves. The only thing we need to do is construct
382 # the other specifiers.
383
384 # We want everything but the last item in the version, but we want to
385 # ignore suffix segments.
386 prefix = _version_join(
387 list(itertools.takewhile(_is_not_suffix, _version_split(spec)))[:-1]
388 )
389
390 # Add the prefix notation to the end of our string
391 prefix += ".*"
392
393 return self._get_operator(">=")(prospective, spec) and self._get_operator("==")(
394 prospective, prefix
395 )
396
397 def _compare_equal(self, prospective: Version, spec: str) -> bool:
398

Callers

nothing calls this directly

Calls 4

_get_operatorMethod · 0.95
_version_joinFunction · 0.85
_version_splitFunction · 0.85
listFunction · 0.50

Tested by

no test coverage detected