diff --git a/setup.cfg b/setup.cfg index a51892f11..c6712bcd7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,9 +53,6 @@ strict_optional = False [mypy-pip/_internal/models/format_control] strict_optional = False -[mypy-pip/_internal/models/link] -strict_optional = False - [mypy-pip/_internal/operations/check] strict_optional = False diff --git a/src/pip/_internal/models/link.py b/src/pip/_internal/models/link.py index 378e94797..01983e707 100644 --- a/src/pip/_internal/models/link.py +++ b/src/pip/_internal/models/link.py @@ -206,5 +206,8 @@ class Link(KeyBasedCompareMixin): """ if not self.has_hash: return False + # Assert non-None so mypy knows self.hash_name and self.hash are str. + assert self.hash_name is not None + assert self.hash is not None return hashes.is_hash_allowed(self.hash_name, hex_digest=self.hash)