Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTERNAL ERROR with __hash__ = None #10134

Closed
nzig opened this issue Feb 25, 2021 · 0 comments · Fixed by #11561
Closed

INTERNAL ERROR with __hash__ = None #10134

nzig opened this issue Feb 25, 2021 · 0 comments · Fixed by #11561

Comments

@nzig
Copy link

nzig commented Feb 25, 2021

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
@nzig nzig added the crash label Feb 25, 2021
97littleleaf11 pushed a commit that referenced this issue Nov 18, 2021
Now we can override attributes with methods.

Closes #10134
Closes #11556

Co-authored-by: Alex Waygood <[email protected]>
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this issue Jan 20, 2022
…n#11561)

Now we can override attributes with methods.

Closes python#10134
Closes python#11556

Co-authored-by: Alex Waygood <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants