Skip to content

INTERNAL ERROR in master branch related to recent support for setter types being different from getter types #18648

Closed
@dlech

Description

@dlech

Crash Report

I was running mypy from the master branch because I wanted to try out the changes from #18510. It looks like there is a bug in the implementation with regard to inheritance (the type in question is overriding an abstract property from an abstract base class).

Traceback

C:\Users\extra\work\pywinrt\_install\release\winrt\_winrt_windows_ui_input_inking.pyi:335: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.16.0+dev.653fc9bb79a8e45dcd6bc89fa9f24c5d170deeca
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Scripts\mypy.exe\__main__.py", line 7, in <module>
    sys.exit(console_entry())
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\__main__.py", line 15, in console_entry
    main()
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\main.py", line 119, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\main.py", line 203, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\build.py", line 191, in build
    result = _build(
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\build.py", line 267, in _build
    graph = dispatch(sources, manager, stdout)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\build.py", line 2937, in dispatch
    process_graph(graph, manager)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\build.py", line 3335, in process_graph
    process_stale_scc(graph, scc, manager)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\build.py", line 3436, in process_stale_scc
    graph[id].type_check_first_pass()
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\build.py", line 2309, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 469, in check_first_pass
    self.accept(d)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 578, in accept
    stmt.accept(self)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\nodes.py", line 1200, in accept
    return visitor.visit_class_def(self)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 2549, in visit_class_def
    self.accept(defn.defs)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 578, in accept
    stmt.accept(self)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\nodes.py", line 1281, in accept
    return visitor.visit_block(self)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 3043, in visit_block
    self.accept(s)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 578, in accept
    stmt.accept(self)
    ~~~~~~~~~~~^^^^^^
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\nodes.py", line 583, in accept
    return visitor.visit_overloaded_func_def(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 637, in visit_overloaded_func_def
    self._visit_overloaded_func_def(defn)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 693, in _visit_overloaded_func_def
    found_method_base_classes = self.check_method_override(defn)
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 2017, in check_method_override
    result = self.check_method_or_accessor_override_for_base(
        defn, base, check_override_compatibility
    )
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 2055, in check_method_or_accessor_override_for_base
    if self.check_method_override_for_base_with_name(defn, name, base):
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 2150, in check_method_override_for_base_with_name
    self.check_setter_type_override(defn, base_attr, base)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 2079, in check_setter_type_override
    original_type, is_original_setter = get_raw_setter_type(base_node)
                                        ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "C:\Users\extra\pipx\.cache\b97425f42183061\Lib\site-packages\mypy\checker.py", line 8888, in get_raw_setter_type
    assert var.type is not None
           ^^^^^^^^^^^^^^^^^^^^
AssertionError:
C:\Users\extra\work\pywinrt\_install\release\winrt\_winrt_windows_ui_input_inking.pyi:335: : note: use --pdb to drop into pdb

To Reproduce

It will take me some time to make a minimal reproducible test case if the stack trace is not enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashtopic-descriptorsProperties, class vs. instance attributestopic-inheritanceInheritance and incompatible overrides

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions