Skip to content

Assertion error, importing library with typehints #8481

Closed
@Stonedestroyer

Description

@Stonedestroyer

Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request?
    Bug, assertionerror
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.

Library used Rapptz/discord.py#1497.

Code

import discord

Running mypy --strict file.py crashes it but if you do normal run without strict and then strict it works until you do strict again. It seems doing strict off the bat without having ran without --strict previous crashes it.

Traceback

Traceback (most recent call last):
  File "C:\Python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\stonedestroyer\bot\.venv\Scripts\mypy.exe\__main__.py", line 7, in <module>
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\__main__.py", line 8, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\main.py", line 89, in main
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\build.py", line 180, in build
    result = _build(
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\build.py", line 249, in _build
    graph = dispatch(sources, manager, stdout)
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\build.py", line 2649, in dispatch
    process_graph(graph, manager)
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\build.py", line 2956, in process_graph
    process_stale_scc(graph, scc, manager)
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\build.py", line 3074, in process_stale_scc
    graph[id].write_cache()
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\build.py", line 2266, in write_cache
    new_interface_hash, self.meta = write_cache(
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\build.py", line 1441, in write_cache
    data = tree.serialize()
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\nodes.py", line 302, in serialize
    'names': self.names.serialize(self._fullname),
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\nodes.py", line 3097, in serialize
    data[key] = value.serialize(fullname, key)
  File "c:\stonedestroyer\bot\.venv\lib\site-packages\mypy\nodes.py", line 3033, in serialize
    assert not isinstance(self.node, PlaceholderNode)
AssertionError

Same issue with latest mypy from master.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions