python / python/mypy

any reason why ExtendedTraverserVisitor does not set allow_interpreted_subclasses=True?

Open
#14,736 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-plugins
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Feature

I got a TypeError: interpreted classes cannot inherit from compiled when I tried to extend from it. Not sure if this is a bug or not.

To reproduce:

from mypy.parse import parse
from mypy.traverser import ExtendedTraverserVisitor

class FooVisitor(ExtendedTraverserVisitor):
    def visit(self, o: Node) -> bool:
        print("hello")
        return True

parse("print('foo')", None, None, None, Options()).accept(FooVisitor())

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading mypy/traverser.py, especially ExtendedTraverserVisitor, and mypy/parse.py to understand how the parsed tree reaches the visitor. Reproduce the TypeError with the example, then determine whether enabling interpreted subclasses is intended and verify the chosen behavior with a focused test or documented rationale.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.