Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
AttributeError: 'NoneType' object has no attribute 'is_hash_allowed' #6772
pip list --outdated --format=columns
After that exception was raised.
How to Reproduce
(env) project (develop) $ pip list --outdated --format=columns ERROR: Exception: Traceback (most recent call last): File "/project/env/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 188, in main status = self.run(options, args) File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 156, in run packages = self.get_outdated(packages, options) File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 164, in get_outdated dist for dist in self.iter_packages_latest_infos(packages, options) File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 164, in <listcomp> dist for dist in self.iter_packages_latest_infos(packages, options) File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 195, in iter_packages_latest_infos best_candidate = evaluator.get_best_candidate(all_candidates) File "/project/env/lib/python3.6/site-packages/pip/_internal/index.py", line 729, in get_best_candidate best_candidate = max(candidates, key=self._sort_key) File "/project/env/lib/python3.6/site-packages/pip/_internal/index.py", line 710, in _sort_key has_allowed_hash = int(link.is_hash_allowed(self._hashes)) File "/project/env/lib/python3.6/site-packages/pip/_internal/models/link.py", line 213, in is_hash_allowed return hashes.is_hash_allowed(self.hash_name, hex_digest=self.hash) AttributeError: 'NoneType' object has no attribute 'is_hash_allowed'
Same issue on Fedora 29, Python 3.7.3.
For now, as a workaround, ...
python3 -m pip install -UI --user 'pip<19.2'
$ python3 -m pip install -UI --user 'pip<19.2' Collecting pip<19.2 Using cached https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl Installing collected packages: pip Successfully installed pip-19.2
Why does it report
Thanks for the confirmation of this occurring on multiple OSes!
Folks, if you're facing the same issue, please don't post additional comments. Please use GitHub reactions to upvote the first post and subscribe to the issue.
That way the maintainers would be able to have a discussion on how to resolve this in this issue -- additional "me too" comments won't help anyone.
After a quick look, I think a good fix for now may be to update
Ahhh. Yep -- strict_optional is False for
Yea, we can't completely rely on it, as long as we have these flags for incremental adoption.
Yea - mypy does checks at the call site, using the rules at the call site.
Your suggested fix and PR look good to me. If we don't see any other issue come up, I can do the bugfix release in the evening today -- ~3-5 hours from now.