Thanks to visit codestin.com
Credit goes to github.com

Skip to content

INTERNAL ERROR with __hash__ = None #10134

Description

@nzig

Crash Report

Mypy crashed when run on the following reduced file. Setting __hash__ to None is the way to suppress Python's default hash method.

Traceback

> mypy mypy_crash.py --show-traceback
mypy_crash.py:2: error: Incompatible types in assignment (expression has type "None", base class "object" defined the type as "Callable[[object], int]")
mypy_crash.py:5: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.820+dev.15bd486a67a3214fdb854ba2f1d6d524113da6c1
Traceback (most recent call last):
  File "/home/user/.virtualenvs/mypy/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/__main__.py", line 11, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/main.py", line 98, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/build.py", line 180, in build
    sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr, extra_plugins
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/build.py", line 253, in _build
    graph = dispatch(sources, manager, stdout)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/build.py", line 2688, in dispatch
    process_graph(graph, manager)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/build.py", line 3012, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/build.py", line 3119, in process_stale_scc
    if not graph[id].type_check_second_pass():
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/build.py", line 2181, in type_check_second_pass
    return self.type_checker().check_second_pass()
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 344, in check_second_pass
    self.check_partial(node)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 356, in check_partial
    self.accept(node)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 401, in accept
    stmt.accept(self)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/nodes.py", line 687, in accept
    return visitor.visit_func_def(self)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 726, in visit_func_def
    self._visit_func_def(defn)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 737, in _visit_func_def
    self.check_method_override(defn)
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 1420, in check_method_override
    if self.check_method_or_accessor_override_for_base(defn, base):
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 1448, in check_method_or_accessor_override_for_base
    if self.check_method_override_for_base_with_name(defn, name, base):
  File "/home/user/.virtualenvs/mypy/lib/python3.6/site-packages/mypy/checker.py", line 1509, in check_method_override_for_base_with_name
    assert False, str(base_attr.node)
AssertionError: Var(__hash__)
mypy_crash.py:5: : note: use --pdb to drop into pdb

To Reproduce

Contents of mypy_crash.py:

class Base:
    __hash__ = None

class Dervied(Base):
    def __hash__(self) -> int:
        return 0

Your Environment

  • Mypy version used: master (0.820+dev.15bd486a67a3214fdb854ba2f1d6d524113da6c1)
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.6.12 (compiled from source with pyenv)
  • Operating system and version: Ubuntu 20.04

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions