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

Method contains

tools/gyp/pylib/packaging/specifiers.py:535–579  ·  view source on GitHub ↗

Return whether or not the item is contained in this specifier. :param item: The item to check for, which can be a version string or a :class:`Version` instance. :param prereleases: Whether or not to match prereleases with this Specifier. If set to

(
        self, item: UnparsedVersion, prereleases: Optional[bool] = None
    )

Source from the content-addressed store, hash-verified

533 return self.contains(item)
534
535 def contains(
536 self, item: UnparsedVersion, prereleases: Optional[bool] = None
537 ) -> bool:
538 """Return whether or not the item is contained in this specifier.
539
540 :param item:
541 The item to check for, which can be a version string or a
542 :class:`Version` instance.
543 :param prereleases:
544 Whether or not to match prereleases with this Specifier. If set to
545 ``None`` (the default), it uses :attr:`prereleases` to determine
546 whether or not prereleases are allowed.
547
548 >>> Specifier(">=1.2.3").contains("1.2.3")
549 True
550 >>> Specifier(">=1.2.3").contains(Version("1.2.3"))
551 True
552 >>> Specifier(">=1.2.3").contains("1.0.0")
553 False
554 >>> Specifier(">=1.2.3").contains("1.3.0a1")
555 False
556 >>> Specifier(">=1.2.3", prereleases=True).contains("1.3.0a1")
557 True
558 >>> Specifier(">=1.2.3").contains("1.3.0a1", prereleases=True)
559 True
560 """
561
562 # Determine if prereleases are to be allowed or not.
563 if prereleases is None:
564 prereleases = self.prereleases
565
566 # Normalize item to a Version, this allows us to have a shortcut for
567 # "2.0" in Specifier(">=2")
568 normalized_item = _coerce_version(item)
569
570 # Determine if we should be supporting prereleases in this specifier
571 # or not, if we do not support prereleases than we can short circuit
572 # logic if this version is a prereleases.
573 if normalized_item.is_prerelease and not prereleases:
574 return False
575
576 # Actually do the comparison to determine if this item is contained
577 # within this Specifier or not.
578 operator_callable: CallableOperator = self._get_operator(self.operator)
579 return operator_callable(normalized_item, self.version)
580
581 def filter(
582 self, iterable: Iterable[UnparsedVersionVar], prereleases: Optional[bool] = None

Callers 15

__contains__Method · 0.95
filterMethod · 0.95
_eval_opFunction · 0.95
containsMethod · 0.45
testdriver.jsFile · 0.45
getNodeSystemFunction · 0.45
isPartOfTypeNodeFunction · 0.45
tryResolveFunction · 0.45
addAntecedentFunction · 0.45

Calls 2

_get_operatorMethod · 0.95
_coerce_versionFunction · 0.85

Tested by

no test coverage detected