KEMBAR78
Unresolved references + tuples crashes mypy · Issue #10400 · python/mypy · GitHub
Skip to content

Unresolved references + tuples crashes mypy #10400

@A5rocks

Description

@A5rocks

Crash Report

Uhh.. mypy crashed? Not sure what to put here...

Traceback

(running dev version, and I put a few print statements to figure out what was erroring, so the line numbers may be off)

$ mypy repro.py

Traceback (most recent call last):
  File "/home/a5/.virtualenvs/mypyplay/bin/mypy", line 33, in <module>
    sys.exit(load_entry_point('mypy', 'console_scripts', 'mypy')())
  File "/home/a5/mypy/mypy/__main__.py", line 11, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "/home/a5/mypy/mypy/main.py", line 98, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "/home/a5/mypy/mypy/build.py", line 179, in build
    result = _build(
  File "/home/a5/mypy/mypy/build.py", line 253, in _build
    graph = dispatch(sources, manager, stdout)
  File "/home/a5/mypy/mypy/build.py", line 2688, in dispatch
    process_graph(graph, manager)
  File "/home/a5/mypy/mypy/build.py", line 3012, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/home/a5/mypy/mypy/build.py", line 3104, in process_stale_scc
    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
  File "/home/a5/mypy/mypy/semanal_main.py", line 82, in semantic_analysis_for_scc
    apply_semantic_analyzer_patches(patches)
  File "/home/a5/mypy/mypy/semanal.py", line 5092, in apply_semantic_analyzer_patches
    patch_func()
  File "/home/a5/mypy/mypy/semanal.py", line 1552, in <lambda>
    self.schedule_patch(PRIORITY_FALLBACKS, lambda: calculate_tuple_fallback(base))
  File "/home/a5/mypy/mypy/semanal_shared.py", line 234, in calculate_tuple_fallback
    fallback.args = (join.join_type_list(list(typ.items)),) + fallback.args[1:]
  File "/home/a5/mypy/mypy/join.py", line 533, in join_type_list
    joined = join_types(joined, t)
  File "/home/a5/mypy/mypy/join.py", line 106, in join_types
    return t.accept(TypeJoinVisitor(s))
  File "/home/a5/mypy/mypy/types.py", line 1963, in accept
    assert isinstance(visitor, SyntheticTypeVisitor)
AssertionError

To Reproduce

from typing import Tuple

class Foo:
    ...

class Bar(aaaaaaaaaa):
    ...

class FooBarTuple(Tuple[Foo, Bar]):
    ...

Your Environment

  • Mypy version used: dev
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.8.2
  • Operating system and version: debian 10

Relevant notes:

Changing FooBarTuple to:

class FooBarTuple(Tuple[Bar]):
    ...

outputs the expected values (that aaaaaaaaaa is undefined).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions