Buckets:
MisterAI/LocalAI_Demo_backends / cpu-diffusers /venv /lib /python3.10 /site-packages /setuptools /_reqs.py
| from __future__ import annotations | |
| from collections.abc import Callable, Iterable, Iterator | |
| from functools import lru_cache | |
| from typing import TYPE_CHECKING, TypeVar, overload | |
| from jaraco import text | |
| from packaging.requirements import Requirement | |
| if TYPE_CHECKING: | |
| from typing import TypeAlias | |
| _T = TypeVar("_T") | |
| _StrOrIter: TypeAlias = str | Iterable[str] | |
| 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 | |
| def parse(strs: _StrOrIter) -> Iterator[Requirement]: ... | |
| 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] | |
| """ | |
| Parse requirements. | |
| """ | |
| return map(parser, parse_strings(strs)) | |
Xet Storage Details
- Size:
- 1.35 kB
- Xet hash:
- 9af6a1e8834475f0f7f20bf0966e5cdd8a503daa2a541adcd220b55282d62de5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.