Skip to content

Commit 32e67ce

Browse files
committed
pylock: read upload_time
1 parent c65343c commit 32e67ce

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/pip/_internal/models/pylock.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44
import sys
55
from dataclasses import dataclass
6+
from datetime import datetime
67
from pathlib import Path
78
from typing import (
89
TYPE_CHECKING,
@@ -271,7 +272,7 @@ class PackageArchive:
271272
url: Optional[str]
272273
path: Optional[str]
273274
size: Optional[int]
274-
# (not supported) upload_time: Optional[datetime]
275+
upload_time: Optional[datetime]
275276
hashes: Dict[str, str]
276277
subdirectory: Optional[str]
277278

@@ -285,6 +286,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
285286
url=_get(d, str, "url"),
286287
path=_get(d, str, "path"),
287288
size=_get(d, int, "size"),
289+
upload_time=_get(d, datetime, "upload-time"),
288290
hashes=_get_required(d, dict, "hashes"),
289291
subdirectory=_get(d, str, "subdirectory"),
290292
)
@@ -293,7 +295,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
293295
@dataclass
294296
class PackageSdist:
295297
name: str
296-
# (not supported) upload_time: Optional[datetime]
298+
upload_time: Optional[datetime]
297299
url: Optional[str]
298300
path: Optional[str]
299301
size: Optional[int]
@@ -307,6 +309,7 @@ def __post_init__(self) -> None:
307309
def from_dict(cls, d: Dict[str, Any]) -> "Self":
308310
return cls(
309311
name=_get_required(d, str, "name"),
312+
upload_time=_get(d, datetime, "upload-time"),
310313
url=_get(d, str, "url"),
311314
path=_get(d, str, "path"),
312315
size=_get(d, int, "size"),
@@ -317,7 +320,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
317320
@dataclass
318321
class PackageWheel:
319322
name: str
320-
# (not supported) upload_time: Optional[datetime]
323+
upload_time: Optional[datetime]
321324
url: Optional[str]
322325
path: Optional[str]
323326
size: Optional[int]
@@ -331,6 +334,7 @@ def __post_init__(self) -> None:
331334
def from_dict(cls, d: Dict[str, Any]) -> "Self":
332335
wheel = cls(
333336
name=_get_required(d, str, "name"),
337+
upload_time=_get(d, datetime, "upload-time"),
334338
url=_get(d, str, "url"),
335339
path=_get(d, str, "path"),
336340
size=_get(d, int, "size"),

src/pip/_internal/utils/pylock.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _pylock_package_from_install_requirement(
6262
url=download_info.url,
6363
path=None,
6464
size=None, # not supported
65+
upload_time=None, # not supported
6566
hashes=download_info.info.hashes,
6667
subdirectory=download_info.subdirectory,
6768
)
@@ -78,6 +79,7 @@ def _pylock_package_from_install_requirement(
7879
package_wheels = [
7980
PackageWheel(
8081
name=link.filename,
82+
upload_time=None, # not supported
8183
url=download_info.url,
8284
path=None,
8385
size=None, # not supported
@@ -87,6 +89,7 @@ def _pylock_package_from_install_requirement(
8789
else:
8890
package_sdist = PackageSdist(
8991
name=link.filename,
92+
upload_time=None, # not supported
9093
url=download_info.url,
9194
path=None,
9295
size=None, # not supported

tests/unit/test_pylock.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime
12
from pathlib import Path
23

34
import pytest
@@ -239,6 +240,7 @@ def test_pylock_tool() -> None:
239240
"sdist": {
240241
"name": "example-1.0.tar.gz",
241242
"path": "./example-1.0.tar.gz",
243+
"upload-time": datetime(2023, 10, 1, 0, 0),
242244
"hashes": {"sha256": "f" * 40},
243245
},
244246
"tool": {"pip": {"foo": "bar"}},

0 commit comments

Comments
 (0)