Skip to content

"TypeError: interpreted classes cannot inherit from compiled" after get_customize_class_mro_hook #6706

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
kedder opened this issue Apr 21, 2019 · 6 comments · Fixed by #7075
Labels
crash priority-0-high topic-plugins The plugin API and ideas for new plugins

Comments

@kedder
Copy link

kedder commented Apr 21, 2019

When using plugin, that provides get_customize_class_mro_hook, mypy errors out with TypeError: interpreted classes cannot inherit from compiled traceback. Tested on mypy-0.701 and python-3.6.

Consider this minimal plugin:

from mypy.plugin import Plugin

class DummyPlugin(Plugin):
    def get_customize_class_mro_hook(self, fullname):
        def analyze(classdef_ctx):
            pass
        return analyze

def plugin(version):
    return DummyPlugin

When mypy is run with this plugin enabled on simple python file, e.g.

class Something:
    pass

Mypy will error out with this traceback:

tmp/sample.py:1: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.701
Traceback (most recent call last):
  File "ve/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
  File "mypy/semanal.py", line 3791, in accept
  File "mypy/nodes.py", line 895, in accept__Node_glue
  File "mypy/nodes.py", line 896, in accept
  File "mypy/semanal.py", line 804, in visit_class_def__StatementVisitor_glue
  File "mypy/semanal.py", line 807, in visit_class_def
  File "mypy/semanal.py", line 819, in analyze_class
  File "mypy/semanal.py", line 1229, in analyze_base_classes
  File "mypy/semanal.py", line 1250, in calculate_class_mro
TypeError: interpreted classes cannot inherit from compiled
tmp/sample.py:1: : note: use --pdb to drop into pdb
@msullivan
Copy link
Collaborator

Could you give the full code for the plugin, with imports?

@ilevkivskyi ilevkivskyi added crash topic-plugins The plugin API and ideas for new plugins labels Apr 22, 2019
@msullivan
Copy link
Collaborator

(Nevermind, I managed to reproduce it.)

@msullivan
Copy link
Collaborator

The error message here is a bad one from mypyc. The actual problem here is that we are trying to instantiate Expression, which is a trait, which is not really supported.

@glyph
Copy link

glyph commented Jun 26, 2019

I believe that this broke / is blocking the zope.interface plugin (see also #3960) Shoobx/mypy-zope#7 - should it be treated as a regression?

@msullivan
Copy link
Collaborator

... I tracked this down and then forgot to fix it. I'll fix it now.

msullivan added a commit that referenced this issue Jun 27, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
)

The semanal code that invoked it created an `Expression` directly,
which mypyc barfs on because it is a trait.

Fixes #6706.
@glyph
Copy link

glyph commented Jul 6, 2019

Thanks so much, @msullivan !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash priority-0-high topic-plugins The plugin API and ideas for new plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants