Compare commits

...

4 Commits

Author SHA1 Message Date
Shantanu 48a3bcbb7b
Merge af706bce36 into 2a0acb595c 2023-11-15 20:22:43 +01:00
hauntsaninja af706bce36 Merge remote-tracking branch 'upstream/main' into legacy-resol 2023-09-25 12:01:06 -07:00
hauntsaninja e261330e65 old comment 2023-09-25 12:00:51 -07:00
hauntsaninja 170b2c18ae Use strict optional checking in legacy resolver
The assert in _set_req_to_reinstall is definitely correct, the three
call sites have guards

The assert in _populate_link is a little trickier. It's not obvious to
me how to prove it will never trigger. Note that if link were ever None,
it could potentially cause AttributeError in Cache._get_cache_path_parts
and direct_url_from_link

The assert in _resolve_one is safe, if req_to_install.name was None it
would raise TypeError in canonicalize_name

I can't prove that req.name is not None in get_installation_order
and the code would work fine if that were the case (since it's a
defaultdict), so I opted to just ignore
2023-09-23 18:05:44 -07:00
2 changed files with 5 additions and 4 deletions

View File

@ -10,9 +10,6 @@ for sub-dependencies
a. "first found, wins" (where the order is breadth first)
"""
# The following comment should be removed at some point in the future.
# mypy: strict-optional=False
import logging
import sys
from collections import defaultdict
@ -323,6 +320,7 @@ class Resolver(BaseResolver):
"""
# Don't uninstall the conflict if doing a user install and the
# conflict is not a user install.
assert req.satisfied_by is not None
if not self.use_user_site or req.satisfied_by.in_usersite:
req.should_reinstall = True
req.satisfied_by = None
@ -421,6 +419,8 @@ class Resolver(BaseResolver):
if self.wheel_cache is None or self.preparer.require_hashes:
return
assert req.link is not None, "_find_requirement_link unexpectedly returned None"
cache_entry = self.wheel_cache.get_cache_entry(
link=req.link,
package_name=req.name,
@ -534,6 +534,7 @@ class Resolver(BaseResolver):
with indent_log():
# We add req_to_install before its dependencies, so that we
# can refer to it when adding dependencies.
assert req_to_install.name is not None
if not requirement_set.has_requirement(req_to_install.name):
# 'unnamed' requirements will get added here
# 'unnamed' requirements can only come from being directly
@ -589,7 +590,7 @@ class Resolver(BaseResolver):
if req.constraint:
return
ordered_reqs.add(req)
for dep in self._discovered_dependencies[req.name]:
for dep in self._discovered_dependencies[req.name]: # type: ignore[index]
schedule(dep)
order.append(req)