Skip to content

Commit 2cc714c

Browse files
committed
Fix merge errors and rename to "exclude-newer-than"
1 parent e1e72e7 commit 2cc714c

File tree

8 files changed

+42
-36
lines changed

8 files changed

+42
-36
lines changed

src/pip/_internal/cli/cmdoptions.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -798,31 +798,32 @@ def _handle_dependency_group(
798798
)
799799

800800

801-
def _handle_upload_before(
801+
def _handle_exclude_newer_than(
802802
option: Option, opt: str, value: str, parser: OptionParser
803803
) -> None:
804804
"""
805-
Process a value provided for the --upload-before option.
805+
Process a value provided for the --exclude-newer-than option.
806806
807-
This is an optparse.Option callback for the --upload-before option.
807+
This is an optparse.Option callback for the --exclude-newer-than option.
808808
"""
809809
if value is None:
810810
return None
811-
upload_before = datetime.datetime.fromisoformat(value)
811+
exclude_newer_than = datetime.datetime.fromisoformat(value)
812812
# Assume local timezone if no offset is given in the ISO string.
813-
if upload_before.tzinfo is None:
814-
upload_before = upload_before.astimezone()
815-
parser.values.upload_before = upload_before
813+
if exclude_newer_than.tzinfo is None:
814+
exclude_newer_than = exclude_newer_than.astimezone()
815+
parser.values.exclude_newer_than = exclude_newer_than
816816

817817

818-
upload_before: Callable[..., Option] = partial(
818+
exclude_newer_than: Callable[..., Option] = partial(
819819
Option,
820-
"--upload-before",
821-
dest="upload_before",
820+
"--exclude-newer-than",
821+
dest="exclude_newer_than",
822822
metavar="datetime",
823823
action="callback",
824-
callback=_handle_upload_before,
825-
help="Skip uploads after given time. This should be an ISO 8601 string.",
824+
callback=_handle_exclude_newer_than,
825+
type="str",
826+
help="Exclude packages newer than given time. This should be an ISO 8601 string.",
826827
)
827828

828829
no_build_isolation: Callable[..., Option] = partial(

src/pip/_internal/cli/req_command.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
PackageFinder machinery and all its vendored dependencies, etc.
66
"""
77

8+
import datetime
89
import logging
910
from functools import partial
1011
from optparse import Values
@@ -326,7 +327,7 @@ def _build_package_finder(
326327
session: PipSession,
327328
target_python: TargetPython | None = None,
328329
ignore_requires_python: bool | None = None,
329-
upload_before: datetime.datetime | None = None,
330+
exclude_newer_than: datetime.datetime | None = None,
330331
) -> PackageFinder:
331332
"""
332333
Create a package finder appropriate to this requirement command.
@@ -347,5 +348,5 @@ def _build_package_finder(
347348
link_collector=link_collector,
348349
selection_prefs=selection_prefs,
349350
target_python=target_python,
350-
upload_before=upload_before,
351+
exclude_newer_than=exclude_newer_than,
351352
)

src/pip/_internal/commands/download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def add_options(self) -> None:
5151
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
5252
self.cmd_opts.add_option(cmdoptions.check_build_deps())
5353
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
54-
self.cmd_opts.add_option(cmdoptions.upload_before())
54+
self.cmd_opts.add_option(cmdoptions.exclude_newer_than())
5555

5656
self.cmd_opts.add_option(
5757
"-d",
@@ -94,7 +94,7 @@ def run(self, options: Values, args: list[str]) -> int:
9494
session=session,
9595
target_python=target_python,
9696
ignore_requires_python=options.ignore_requires_python,
97-
upload_before=options.upload_before,
97+
exclude_newer_than=options.exclude_newer_than,
9898
)
9999

100100
build_tracker = self.enter_context(get_build_tracker())

src/pip/_internal/commands/index.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def add_options(self) -> None:
3838
cmdoptions.add_target_python_options(self.cmd_opts)
3939

4040
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
41-
self.cmd_opts.add_option(cmdoptions.upload_before())
41+
self.cmd_opts.add_option(cmdoptions.exclude_newer_than())
4242
self.cmd_opts.add_option(cmdoptions.pre())
4343
self.cmd_opts.add_option(cmdoptions.json())
4444
self.cmd_opts.add_option(cmdoptions.no_binary())
@@ -85,7 +85,7 @@ def _build_package_finder(
8585
session: PipSession,
8686
target_python: TargetPython | None = None,
8787
ignore_requires_python: bool | None = None,
88-
upload_before: datetime.datetime | None = None,
88+
exclude_newer_than: datetime.datetime | None = None,
8989
) -> PackageFinder:
9090
"""
9191
Create a package finder appropriate to the index command.
@@ -103,7 +103,7 @@ def _build_package_finder(
103103
link_collector=link_collector,
104104
selection_prefs=selection_prefs,
105105
target_python=target_python,
106-
upload_before=upload_before,
106+
exclude_newer_than=exclude_newer_than,
107107
)
108108

109109
def get_available_package_versions(self, options: Values, args: list[Any]) -> None:
@@ -119,7 +119,7 @@ def get_available_package_versions(self, options: Values, args: list[Any]) -> No
119119
session=session,
120120
target_python=target_python,
121121
ignore_requires_python=options.ignore_requires_python,
122-
upload_before=options.upload_before,
122+
exclude_newer_than=options.exclude_newer_than,
123123
)
124124

125125
versions: Iterable[Version] = (

src/pip/_internal/commands/install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def add_options(self) -> None:
207207
),
208208
)
209209

210-
self.cmd_opts.add_option(cmdoptions.upload_before())
210+
self.cmd_opts.add_option(cmdoptions.exclude_newer_than())
211211
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
212212
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
213213
self.cmd_opts.add_option(cmdoptions.use_pep517())
@@ -345,7 +345,7 @@ def run(self, options: Values, args: list[str]) -> int:
345345
session=session,
346346
target_python=target_python,
347347
ignore_requires_python=options.ignore_requires_python,
348-
upload_before=options.upload_before,
348+
exclude_newer_than=options.exclude_newer_than,
349349
)
350350
build_tracker = self.enter_context(get_build_tracker())
351351

src/pip/_internal/commands/wheel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def add_options(self) -> None:
6464
self.cmd_opts.add_option(cmdoptions.requirements())
6565
self.cmd_opts.add_option(cmdoptions.src())
6666
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
67-
self.cmd_opts.add_option(cmdoptions.upload_before())
67+
self.cmd_opts.add_option(cmdoptions.exclude_newer_than())
6868
self.cmd_opts.add_option(cmdoptions.no_deps())
6969
self.cmd_opts.add_option(cmdoptions.progress_bar())
7070

@@ -107,7 +107,7 @@ def run(self, options: Values, args: list[str]) -> int:
107107
finder = self._build_package_finder(
108108
options=options,
109109
session=session,
110-
upload_before=options.upload_before,
110+
exclude_newer_than=options.exclude_newer_than,
111111
)
112112

113113
options.wheel_dir = normalize_path(options.wheel_dir)

src/pip/_internal/index/package_finder.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Routines related to PyPI, indexes"""
2+
from __future__ import annotations
23

4+
import datetime
35
import enum
46
import functools
57
import itertools
@@ -131,7 +133,7 @@ def __init__(
131133
target_python: TargetPython,
132134
allow_yanked: bool,
133135
ignore_requires_python: Optional[bool] = None,
134-
upload_before: Optional[datetime.datetime] = None,
136+
exclude_newer_than: Optional[datetime.datetime] = None,
135137
) -> None:
136138
"""
137139
:param project_name: The user supplied package name.
@@ -149,7 +151,7 @@ def __init__(
149151
:param ignore_requires_python: Whether to ignore incompatible
150152
PEP 503 "data-requires-python" values in HTML links. Defaults
151153
to False.
152-
:param upload_before: If set, only allow links prior to the given date.
154+
:param exclude_newer_than: If set, only allow links prior to the given date.
153155
"""
154156
if ignore_requires_python is None:
155157
ignore_requires_python = False
@@ -159,7 +161,7 @@ def __init__(
159161
self._ignore_requires_python = ignore_requires_python
160162
self._formats = formats
161163
self._target_python = target_python
162-
self._upload_before = upload_before
164+
self._exclude_newer_than = exclude_newer_than
163165

164166
self.project_name = project_name
165167

@@ -178,9 +180,9 @@ def evaluate_link(self, link: Link) -> tuple[LinkType, str]:
178180
reason = link.yanked_reason or "<none given>"
179181
return (LinkType.yanked, f"yanked for reason: {reason}")
180182

181-
if link.upload_time is not None and self._upload_before is not None:
182-
if link.upload_time > self._upload_before:
183-
reason = f"Upload time {link.upload_time} after {self._upload_before}"
183+
if link.upload_time is not None and self._exclude_newer_than is not None:
184+
if link.upload_time > self._exclude_newer_than:
185+
reason = f"Upload time {link.upload_time} after {self._exclude_newer_than}"
184186
return (LinkType.upload_too_late, reason)
185187

186188
if link.egg_fragment:
@@ -600,7 +602,7 @@ def __init__(
600602
format_control: Optional[FormatControl] = None,
601603
candidate_prefs: Optional[CandidatePreferences] = None,
602604
ignore_requires_python: Optional[bool] = None,
603-
upload_before: Optional[datetime.datetime] = None,
605+
exclude_newer_than: Optional[datetime.datetime] = None,
604606
) -> None:
605607
"""
606608
This constructor is primarily meant to be used by the create() class
@@ -622,7 +624,7 @@ def __init__(
622624
self._ignore_requires_python = ignore_requires_python
623625
self._link_collector = link_collector
624626
self._target_python = target_python
625-
self._upload_before = upload_before
627+
self._exclude_newer_than = exclude_newer_than
626628

627629
self.format_control = format_control
628630

@@ -646,7 +648,7 @@ def create(
646648
link_collector: LinkCollector,
647649
selection_prefs: SelectionPreferences,
648650
target_python: Optional[TargetPython] = None,
649-
upload_before: Optional[datetime.datetime] = None,
651+
exclude_newer_than: Optional[datetime.datetime] = None,
650652
) -> "PackageFinder":
651653
"""Create a PackageFinder.
652654
@@ -655,7 +657,7 @@ def create(
655657
:param target_python: The target Python interpreter to use when
656658
checking compatibility. If None (the default), a TargetPython
657659
object will be constructed from the running Python.
658-
:param upload_before: If set, only find links prior to the given date.
660+
:param exclude_newer_than: If set, only find links prior to the given date.
659661
"""
660662
if target_python is None:
661663
target_python = TargetPython()
@@ -672,7 +674,7 @@ def create(
672674
allow_yanked=selection_prefs.allow_yanked,
673675
format_control=selection_prefs.format_control,
674676
ignore_requires_python=selection_prefs.ignore_requires_python,
675-
upload_before=upload_before,
677+
exclude_newer_than=exclude_newer_than,
676678
)
677679

678680
@property
@@ -751,7 +753,7 @@ def make_link_evaluator(self, project_name: str) -> LinkEvaluator:
751753
target_python=self._target_python,
752754
allow_yanked=self._allow_yanked,
753755
ignore_requires_python=self._ignore_requires_python,
754-
upload_before=self._upload_before,
756+
exclude_newer_than=self._exclude_newer_than,
755757
)
756758

757759
def _sort_links(self, links: Iterable[Link]) -> list[Link]:

src/pip/_internal/models/link.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import datetime
24
import functools
35
import itertools

0 commit comments

Comments
 (0)