Voice et bot modif

This commit is contained in:
pi 2026-06-16 17:09:34 +00:00
parent 189d56026b
commit 7333a22bcd
10774 changed files with 634644 additions and 933308 deletions

View file

@ -1,14 +1,10 @@
from __future__ import annotations
import collections
import logging
import os
from collections.abc import Container, Generator, Iterable
from dataclasses import dataclass, field
from typing import NamedTuple
from typing import Container, Dict, Generator, Iterable, List, NamedTuple, Optional, Set
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
from pip._vendor.packaging.version import InvalidVersion
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.packaging.version import Version
from pip._internal.exceptions import BadCommand, InstallationError
from pip._internal.metadata import BaseDistribution, get_environment
@ -24,19 +20,19 @@ logger = logging.getLogger(__name__)
class _EditableInfo(NamedTuple):
requirement: str
comments: list[str]
comments: List[str]
def freeze(
requirement: list[str] | None = None,
requirement: Optional[List[str]] = None,
local_only: bool = False,
user_only: bool = False,
paths: list[str] | None = None,
paths: Optional[List[str]] = None,
isolated: bool = False,
exclude_editable: bool = False,
skip: Container[str] = (),
) -> Generator[str, None, None]:
installations: dict[str, FrozenRequirement] = {}
installations: Dict[str, FrozenRequirement] = {}
dists = get_environment(paths).iter_installed_distributions(
local_only=local_only,
@ -54,10 +50,10 @@ def freeze(
# should only be emitted once, even if the same option is in multiple
# requirements files, so we need to keep track of what has been emitted
# so that we don't emit it again if it's seen again
emitted_options: set[str] = set()
emitted_options: Set[str] = set()
# keep track of which files a requirement is in so that we can
# give an accurate warning if a requirement appears multiple times.
req_files: dict[str, list[str]] = collections.defaultdict(list)
req_files: Dict[str, List[str]] = collections.defaultdict(list)
for req_file_path in requirement:
with open(req_file_path) as req_file:
for line in req_file:
@ -86,7 +82,7 @@ def freeze(
yield line
continue
if line.startswith(("-e", "--editable")):
if line.startswith("-e") or line.startswith("--editable"):
if line.startswith("-e"):
line = line[2:].strip()
else:
@ -149,13 +145,10 @@ def freeze(
def _format_as_name_version(dist: BaseDistribution) -> str:
try:
dist_version = dist.version
except InvalidVersion:
# legacy version
return f"{dist.raw_name}==={dist.raw_version}"
else:
dist_version = dist.version
if isinstance(dist_version, Version):
return f"{dist.raw_name}=={dist_version}"
return f"{dist.raw_name}==={dist_version}"
def _get_editable_info(dist: BaseDistribution) -> _EditableInfo:
@ -224,19 +217,22 @@ def _get_editable_info(dist: BaseDistribution) -> _EditableInfo:
)
@dataclass(frozen=True)
class FrozenRequirement:
name: str
req: str
editable: bool
comments: Iterable[str] = field(default_factory=tuple)
@property
def canonical_name(self) -> NormalizedName:
return canonicalize_name(self.name)
def __init__(
self,
name: str,
req: str,
editable: bool,
comments: Iterable[str] = (),
) -> None:
self.name = name
self.canonical_name = canonicalize_name(name)
self.req = req
self.editable = editable
self.comments = comments
@classmethod
def from_dist(cls, dist: BaseDistribution) -> FrozenRequirement:
def from_dist(cls, dist: BaseDistribution) -> "FrozenRequirement":
editable = dist.editable
if editable:
req, comments = _get_editable_info(dist)