Skip to content

Commit 7578589

Browse files
Merge pull request #115 from r1chardj0n3s/remove-dict-handling
Remove handling of now-unsupported pip versions
2 parents 86f1ad3 + a39a1cc commit 7578589

File tree

2 files changed

+30
-40
lines changed

2 files changed

+30
-40
lines changed

pip_check_reqs/find_extra_reqs.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,21 @@ def find_extra_reqs(
4444
]
4545

4646
for package in search_packages_info(all_pkgs):
47-
if isinstance(package, dict): # pragma: no cover
48-
package_name = package["name"]
49-
package_location = package["location"]
50-
package_files = package.get("files", []) or []
51-
else: # pragma: no cover
52-
package_name = package.name
53-
package_location = package.location
54-
package_files = []
55-
for item in package.files or []:
56-
here = pathlib.Path(".").resolve()
57-
item_location_rel = pathlib.Path(package_location) / item
58-
item_location = item_location_rel.resolve()
59-
try:
60-
relative_item_location = item_location.relative_to(here)
61-
except ValueError:
62-
# Ideally we would use Pathlib.is_relative_to rather than
63-
# checking for a ValueError, but that is only available in
64-
# Python 3.9+.
65-
relative_item_location = item_location
66-
package_files.append(str(relative_item_location))
47+
package_name = package.name
48+
package_location = package.location
49+
package_files = []
50+
for item in package.files or []:
51+
here = pathlib.Path(".").resolve()
52+
item_location_rel = pathlib.Path(package_location) / item
53+
item_location = item_location_rel.resolve()
54+
try:
55+
relative_item_location = item_location.relative_to(here)
56+
except ValueError:
57+
# Ideally we would use Pathlib.is_relative_to rather than
58+
# checking for a ValueError, but that is only available in
59+
# Python 3.9+.
60+
relative_item_location = item_location
61+
package_files.append(str(relative_item_location))
6762

6863
log.debug(
6964
"installed package: %s (at %s)", package_name, package_location

pip_check_reqs/find_missing_reqs.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,21 @@ def find_missing_reqs(
4242
]
4343

4444
for package in search_packages_info(all_pkgs):
45-
if isinstance(package, dict): # pragma: no cover
46-
package_name = package["name"]
47-
package_location = package["location"]
48-
package_files = package.get("files", []) or []
49-
else: # pragma: no cover
50-
package_name = package.name
51-
package_location = package.location
52-
package_files = []
53-
for item in package.files or []:
54-
here = pathlib.Path(".").resolve()
55-
item_location_rel = pathlib.Path(package_location) / item
56-
item_location = item_location_rel.resolve()
57-
try:
58-
relative_item_location = item_location.relative_to(here)
59-
except ValueError:
60-
# Ideally we would use Pathlib.is_relative_to rather than
61-
# checking for a ValueError, but that is only available in
62-
# Python 3.9+.
63-
relative_item_location = item_location
64-
package_files.append(str(relative_item_location))
45+
package_name = package.name
46+
package_location = package.location
47+
package_files = []
48+
for item in package.files or []:
49+
here = pathlib.Path(".").resolve()
50+
item_location_rel = pathlib.Path(package_location) / item
51+
item_location = item_location_rel.resolve()
52+
try:
53+
relative_item_location = item_location.relative_to(here)
54+
except ValueError:
55+
# Ideally we would use Pathlib.is_relative_to rather than
56+
# checking for a ValueError, but that is only available in
57+
# Python 3.9+.
58+
relative_item_location = item_location
59+
package_files.append(str(relative_item_location))
6560

6661
log.debug(
6762
"installed package: %s (at %s)", package_name, package_location

0 commit comments

Comments
 (0)