Skip to content

Conversation

sobolevn
Copy link
Member

Description

Now these types can be extended from plugin code.
Previously it was impossible:

from mypy.type_visitor import TypeVisitor


class KindTranslator(TypeVisitor):
    ...

Was giving:

TypeError: interpreted classes cannot inherit from compiled traits

But, this is a very powerful tool. Some complex type manipulations do require this (or similar) tool.
For example:

More context: #9001 (comment)

Test Plan

I actually don't have any test plan at the moment. I would be very happy to receive any advice! 👍

Now these types can be extended from plugin code.
More context: #9001 (comment)
Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a good idea. It'll increase our generated code size but shouldn't slow things down.

@msullivan msullivan merged commit a9fa9ab into python:master Oct 18, 2020
TH3CHARLie pushed a commit that referenced this pull request Feb 26, 2021
…10125)

Currently a very important tool - which `NodeVisitor` definitely is - is not available to be used in a 3rd party code.
Because currently inheriting from `NodeVisitor` raises an exception: `TypeError: interpreted classes cannot inherit from compiled traits`

A developer has a single choice to replicate the same visitor pattern by themselves, which is not really convenient.
So, I propose to make this consistent with `TypeVisitor`, which already allows having interpreted subclasses.

Refs a9fa9ab
Refs #9001
Refs #9602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants