Skip to content

Commit 421672c

Browse files
committed
pylock: read upload_time
1 parent 8e535ff commit 421672c

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,
@@ -272,7 +273,7 @@ class PackageArchive:
272273
url: Optional[str]
273274
path: Optional[str]
274275
size: Optional[int]
275-
# (not supported) upload_time: Optional[datetime]
276+
upload_time: Optional[datetime]
276277
hashes: Dict[str, str]
277278
subdirectory: Optional[str]
278279

@@ -286,6 +287,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
286287
url=_get(d, str, "url"),
287288
path=_get(d, str, "path"),
288289
size=_get(d, int, "size"),
290+
upload_time=_get(d, datetime, "upload-time"),
289291
hashes=_get_required(d, dict, "hashes"),
290292
subdirectory=_get(d, str, "subdirectory"),
291293
)
@@ -294,7 +296,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
294296
@dataclass
295297
class PackageSdist:
296298
name: str
297-
# (not supported) upload_time: Optional[datetime]
299+
upload_time: Optional[datetime]
298300
url: Optional[str]
299301
path: Optional[str]
300302
size: Optional[int]
@@ -308,6 +310,7 @@ def __post_init__(self) -> None:
308310
def from_dict(cls, d: Dict[str, Any]) -> "Self":
309311
return cls(
310312
name=_get_required(d, str, "name"),
313+
upload_time=_get(d, datetime, "upload-time"),
311314
url=_get(d, str, "url"),
312315
path=_get(d, str, "path"),
313316
size=_get(d, int, "size"),
@@ -318,7 +321,7 @@ def from_dict(cls, d: Dict[str, Any]) -> "Self":
318321
@dataclass
319322
class PackageWheel:
320323
name: str
321-
# (not supported) upload_time: Optional[datetime]
324+
upload_time: Optional[datetime]
322325
url: Optional[str]
323326
path: Optional[str]
324327
size: Optional[int]
@@ -332,6 +335,7 @@ def __post_init__(self) -> None:
332335
def from_dict(cls, d: Dict[str, Any]) -> "Self":
333336
wheel = cls(
334337
name=_get_required(d, str, "name"),
338+
upload_time=_get(d, datetime, "upload-time"),
335339
url=_get(d, str, "url"),
336340
path=_get(d, str, "path"),
337341
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
@@ -61,6 +61,7 @@ def _pylock_package_from_install_requirement(
6161
url=download_info.url,
6262
path=None,
6363
size=None, # not supported
64+
upload_time=None, # not supported
6465
hashes=download_info.info.hashes,
6566
subdirectory=download_info.subdirectory,
6667
)
@@ -77,6 +78,7 @@ def _pylock_package_from_install_requirement(
7778
package_wheels = [
7879
PackageWheel(
7980
name=link.filename,
81+
upload_time=None, # not supported
8082
url=download_info.url,
8183
path=None,
8284
size=None, # not supported
@@ -86,6 +88,7 @@ def _pylock_package_from_install_requirement(
8688
else:
8789
package_sdist = PackageSdist(
8890
name=link.filename,
91+
upload_time=None, # not supported
8992
url=download_info.url,
9093
path=None,
9194
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)