Skip to content

Commit 850e8c5

Browse files
committed
feat(tests): Add optional cutoff to toxgen
1 parent adcfa0f commit 850e8c5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scripts/populate_tox/populate_tox.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import time
1010
from bisect import bisect_left
1111
from collections import defaultdict
12-
from datetime import datetime, timezone
12+
from datetime import datetime, timedelta, timezone # noqa: F401
1313
from importlib.metadata import metadata
1414
from packaging.specifiers import SpecifierSet
1515
from packaging.version import Version
@@ -29,6 +29,10 @@
2929
from split_tox_gh_actions.split_tox_gh_actions import GROUPS
3030

3131

32+
# Set CUTOFF this to a datetime to ignore packages older than CUTOFF
33+
CUTOFF = None
34+
# CUTOFF = datetime.now(tz=timezone.utc) - timedelta(days=365 * 5)
35+
3236
TOX_FILE = Path(__file__).resolve().parent.parent.parent / "tox.ini"
3337
ENV = Environment(
3438
loader=FileSystemLoader(Path(__file__).resolve().parent),
@@ -153,8 +157,14 @@ def _prefilter_releases(
153157
if meta["yanked"]:
154158
continue
155159

160+
uploaded = datetime.fromisoformat(meta["upload_time_iso_8601"])
161+
156162
if older_than is not None:
157-
if datetime.fromisoformat(meta["upload_time_iso_8601"]) > older_than:
163+
if uploaded > older_than:
164+
continue
165+
166+
if CUTOFF is not None:
167+
if uploaded < CUTOFF:
158168
continue
159169

160170
version = Version(release)

0 commit comments

Comments
 (0)