File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -499,8 +499,9 @@ def get_pypi_latest_date(downloads):
499499 latest_date = None
500500 for download in downloads :
501501 upload_time = download .get ("upload_time_iso_8601" )
502- if upload_time :
503- current_date = dateparser .parse (upload_time )
502+ if not upload_time :
503+ continue
504+ current_date = dateparser .parse (upload_time )
504505 if not latest_date :
505506 latest_date = current_date
506507 else :
Original file line number Diff line number Diff line change 1+ # fetchcode is a free software tool from nexB Inc. and others.
2+ # Visit https://github.com/aboutcode-org/fetchcode for support and download.
3+
4+ # Copyright (c) nexB Inc. and others. All rights reserved.
5+ # http://nexb.com and http://aboutcode.org
6+
7+ # This software is licensed under the Apache License version 2.0.
8+
9+ # You may not use this software except in compliance with the License.
10+ # You may obtain a copy of the License at:
11+ # http://apache.org/licenses/LICENSE-2.0
12+ # Unless required by applicable law or agreed to in writing, software distributed
13+ # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+ # CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+ # specific language governing permissions and limitations under the License.
16+
17+ from fetchcode .package_versions import get_pypi_latest_date
18+
19+
20+ def test_pypi_latest_date_skips_missing_upload_times ():
21+ assert get_pypi_latest_date ([{}, {"upload_time_iso_8601" : None }]) is None
22+ result = get_pypi_latest_date (
23+ [
24+ {},
25+ {"upload_time_iso_8601" : "2024-01-02T00:00:00Z" },
26+ {},
27+ {"upload_time_iso_8601" : "2024-01-01T00:00:00Z" },
28+ ]
29+ )
30+ assert result .isoformat () == "2024-01-02T00:00:00+00:00"
You can’t perform that action at this time.
0 commit comments