parse_req: Callable[[str], Requirement] = lru_cache()(Requirement) # Setuptools parses the same requirement many times # (e.g. first for validation than for normalisation), # so it might be worth to cache.
def parse_strings(strs: _StrOrIter) -> Iterator[str]: """ Yield requirement strings for each specification in `strs`.
`strs` must be a string, or a (possibly-nested) iterable thereof. """ return text.join_continuation(map(text.drop_comment, text.yield_lines(strs)))
# These overloads are only needed because of a mypy false-positive, pyright gets it right # https://github.com/python/mypy/issues/3737
@overload def parse(strs: _StrOrIter) -> Iterator[Requirement]: ...
@overload def parse(strs: _StrOrIter, parser: Callable[[str], _T]) -> Iterator[_T]: ... def parse(strs: _StrOrIter, parser: Callable[[str], _T] = parse_req) -> Iterator[_T]: # type: ignore[assignment] """
Replacement for ``pkg_resources.parse_requirements`` that uses ``packaging``. """ return map(parser, parse_strings(strs))
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.