1919from collections import defaultdict
2020from functools import total_ordering
2121from hashlib import sha256
22+ from http import HTTPStatus
2223from typing import List
2324from typing import Optional
2425from typing import Tuple
2526from unittest .mock import MagicMock
2627from urllib .parse import urljoin
2728from uuid import uuid4
28- from http import HTTPStatus
2929
3030import requests
3131import saneyaml
@@ -168,17 +168,14 @@ def nearest_patched_package(
168168 Return a list of Affected Packages for each Patched package.
169169 """
170170
171- vulnerable_packages = sorted (
172- [VersionedPackage (package ) for package in vulnerable_packages ])
173- resolved_packages = sorted ([VersionedPackage (package )
174- for package in resolved_packages ])
171+ vulnerable_packages = sorted ([VersionedPackage (package ) for package in vulnerable_packages ])
172+ resolved_packages = sorted ([VersionedPackage (package ) for package in resolved_packages ])
175173
176174 resolved_package_count = len (resolved_packages )
177175 affected_package_with_patched_package_objects = []
178176
179177 for vulnerable_package in vulnerable_packages :
180- patched_package_index = bisect .bisect_right (
181- resolved_packages , vulnerable_package )
178+ patched_package_index = bisect .bisect_right (resolved_packages , vulnerable_package )
182179 patched_package = None
183180 if patched_package_index < resolved_package_count :
184181 patched_package = resolved_packages [patched_package_index ]
@@ -409,7 +406,7 @@ def base32_custom(btes):
409406 from_bytes = int .from_bytes
410407
411408 for i in range (0 , len (btes ), 5 ):
412- c = from_bytes (btes [i : i + 5 ], "big" )
409+ c = from_bytes (btes [i : i + 5 ], "big" )
413410 encoded += (
414411 _base32_table [c >> 30 ]
415412 + _base32_table [(c >> 20 ) & 0x3FF ] # bits 1 - 10
@@ -426,8 +423,7 @@ def fetch_response(url):
426423 response = requests .get (url )
427424 if response .status_code == HTTPStatus .OK :
428425 return response
429- raise Exception (
430- f"Failed to fetch data from { url !r} with status code: { response .status_code !r} " )
426+ raise Exception (f"Failed to fetch data from { url !r} with status code: { response .status_code !r} " )
431427
432428
433429# This should be a method on PackageURL
0 commit comments