8000 Internal Error on runtime checkable protocol containing a class · Issue #10522 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Internal Error on runtime checkable protocol containing a class #10522

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
Maxpxt opened this issue May 21, 2021 · 1 comment
Closed

Internal Error on runtime checkable protocol containing a class #10522

Maxpxt opened this issue May 21, 2021 · 1 comment

Comments

@Maxpxt
Copy link
Maxpxt commented May 21, 2021

Crash Report

mypy crashed while checking a file defining a runtime checkable protocol that contained another class.

Traceback

mypy_bug.py:4: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.812
Traceback (most recent call last):
  File "c:\programdata\anaconda3\envs\sar39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\programdata\anaconda3\envs\sar39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "mypy\checker.py", line 401, in accept
  File "mypy\nodes.py", line 950, in accept
  File "mypy\checker.py", line 1733, in visit_class_def
  File "mypy\checkmember.py", line 966, in type_object_type
  File "mypy\typeops.py", line 102, in type_object_type_from_function
  File "mypy\typeops.py", line 130, in class_callable
  File "mypy\subtypes.py", line 93, in is_subtype
  File "mypy\subtypes.py", line 135, in _is_subtype
  File "mypy\types.py", line 833, in accept
  File "mypy\subtypes.py", line 264, in visit_instance
  File "mypy\subtypes.py", line 539, in is_protocol_implementation
AssertionError:
mypy_bug.py:4: : note: use --pdb to drop into pdb

To Reproduce

Minimal code that causes the error:

from typing import Protocol, runtime_checkable

@runtime_checkable
class Foo(Protocol):
    class Bar:
        pass

Without @runtime_checkable, mypy runs fine.

Your Environment

  • Mypy version used: mypy 0.812.
  • Mypy command-line flags: None. The command was mypy mypy_bug.py --show-traceback.
  • Mypy configuration options from mypy.ini (and other config files): None. There was no configuration file.
  • Python version used: Python 3.9.2, from a conda (version 4.9.2) environment.
  • Operating system and version: Windows 10 Pro, version 20H2, build 19042.985.
@ilevkivskyi
Copy link
Member

I think this was fixed by my other PR, it works on master.

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

No branches or pull requests

4 participants
0