Skip to content

[DO-NOT-MERGE] populate requirement.specifier on demand #13323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/pip/_vendor/packaging/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# for complete details.
from __future__ import annotations

from functools import cached_property
from typing import Any, Iterator

from ._parser import parse_requirement as _parse_requirement
Expand Down Expand Up @@ -40,12 +41,16 @@ def __init__(self, requirement_string: str) -> None:
self.name: str = parsed.name
self.url: str | None = parsed.url or None
self.extras: set[str] = set(parsed.extras or [])
self.specifier: SpecifierSet = SpecifierSet(parsed.specifier)
self._raw_specifier = parsed.specifier
self.marker: Marker | None = None
if parsed.marker is not None:
self.marker = Marker.__new__(Marker)
self.marker._markers = _normalize_extra_values(parsed.marker)

@cached_property
def specifier(self) -> SpecifierSet:
return SpecifierSet(self._raw_specifier)

def _iter_parts(self, name: str) -> Iterator[str]:
yield name

Expand Down
Loading