Skip to content

crash on @overload together with @singledispatch #10259

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

Closed
shaunc opened this issue Mar 28, 2021 · 1 comment
Closed

crash on @overload together with @singledispatch #10259

shaunc opened this issue Mar 28, 2021 · 1 comment
Labels

Comments

@shaunc
Copy link

shaunc commented Mar 28, 2021

Crash Report

(Tell us what happened.)

I'm trying to tell typing the relation between argument and return types on a singledispatch function:

from functools import singledispatch
from typing import overload


class F:
    ...


class G:
    ...


class F1(F):
    ...


class G1(G):
    ...


class F2(F):
    ...


class G2(G):
    ...


@overload
def foo(f: F1) -> G1:
    ...


@overload
def foo(f: F2) -> G2:
    ...


@singledispatch
def foo(f: F) -> G:
    ...


@foo.register
def foo_1(f: F1) -> G1:
    ...


@foo.register
def foo_2(f: F2) -> G2:
    ...

Traceback

% mypy src/emm/test_sd.py --follow-imports=silent --strict --show-traceback
src/emm/test_sd.py:29: 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: 0.820+dev.f00bb49066810589b5bb122425381ef833fe471b
Traceback (most recent call last):
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/__main__.py", line 11, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/main.py", line 98, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/build.py", line 179, in build
    result = _build(
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/build.py", line 253, in _build
    graph = dispatch(sources, manager, stdout)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/build.py", line 2688, in dispatch
    process_graph(graph, manager)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/build.py", line 3012, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/build.py", line 3110, in process_stale_scc
    graph[id].type_check_first_pass()
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/build.py", line 2164, in type_check_first_pass
    self.type_checker().check_first_pass()
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/checker.py", line 294, in check_first_pass
    self.accept(d)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/checker.py", line 401, in accept
    stmt.accept(self)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/nodes.py", line 526, in accept
    return visitor.visit_overloaded_func_def(self)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/checker.py", line 434, in visit_overloaded_func_def
    self._visit_overloaded_func_def(defn)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/checker.py", line 461, in _visit_overloaded_func_def
    self.check_overlapping_overloads(defn)
  File "/home/shauncutts/.cache/pypoetry/virtualenvs/emm-5s1w60K6-py3.8/lib/python3.8/site-packages/mypy/checker.py", line 482, in check_overlapping_overloads
    assert isinstance(inner_type, CallableType)
AssertionError: 
src/emm/test_sd.py:29: : note: use --pdb to drop into pdb

To Reproduce

The module above suffices

Your Environment

  • Mypy version used: 0.820+dev.f00bb49066810589b5bb122425381ef833fe471b (initially encountered on 0.812)
  • Mypy command-line flags: --follow-imports=silent --strict --show-traceback
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
allow_untyped_calls = False
  • Python version used: 3.8
  • Operating system and version: ubuntu 20.04
@shaunc shaunc added the crash label Mar 28, 2021
@hauntsaninja
Copy link
Collaborator

Dupe of #8356

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants