Skip to content

Crash when (Mutable)Sequence is imported from collections.abc in typeshed/stdlib/builtins.pyi #11860

Closed
@AlexWaygood

Description

@AlexWaygood

Crash Report

Mypy crashes if one or both of Sequence and MutableSequence is imported from collections.abc instead of typing in the typeshed stub for builtins.

Traceback

stdlib\builtins.pyi:1506: error: Unexpected "..."
C:\Users\Alex\Desktop\Code dump\typeshed\stdlib\collections\__init__.pyi: 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.930
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Alex\Desktop\Code dump\typeshed\.venv3\Scripts\mypy.exe\__main__.py", line 7, in <module>
    sys.exit(console_entry())
  File "mypy\build.py", line 1972, in wrap_context
  File "mypy\semanal_main.py", line 326, in semantic_analyze_target
  File "mypy\semanal.py", line 405, in refresh_partial
  File "mypy\semanal.py", line 414, in refresh_top_level
  File "mypy\semanal.py", line 444, in add_implicit_module_attrs
AssertionError:
C:\Users\Alex\Desktop\Code dump\typeshed\stdlib\collections\__init__.pyi: : note: use --pdb to drop into pdb

To Reproduce

  1. Clone typeshed
  2. Change one or both of Sequence and MutableSequence in typeshed/stdlib/builtins.pyi so that they are imported from collections.abc rather than typing.
  3. cd into the typeshed repo.
  4. Run mypy stdlib/functools.py --show-traceback (the file you run mypy on is irrelevant).

Using the typeshed CI, I have reproduced this issue:

  • On MacOS, Windows and Ubuntu
  • On Python versions 3.6-3.10 inclusive.
  • Importing just Sequence from collections.abc; importing just MutableSequence from collections.abc; and importing both Sequence and MutableSequence from collections.abc.

Mypy version used
0.930

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-typeshedAnything that blocks a typeshed changecrashsemantic-analyzerProblems that happen during semantic analysistopic-pep-585PEP 585 (builtin generics)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions