Skip to content

TransformVisitor (and StrConv) are slightly out-of-sync with node definitions #2109

Open
@Michael0x2a

Description

@Michael0x2a

I recently noticed that mypy.treetransform.TransformVisitor seems to be slightly out-of-sync with the nodes within mypy.nodes.

For example...

  • visit_func_def isn't copying over the is_generator, is_coroutine, and is_awaitable_coroutine attributes
  • visit_var isn't copying over the is_suppressed_import attribute
  • visit_with_statement isn't copying over is_async
  • visit_class_def isn't copying over has_incompatible_baseclass

Currently, it doesn't seem like these omissions are too harmful since the only place we use TransformVisitor is within TypeTransformVisitor (which only expands types). However, I could see this might lead to subtle bugs in the future, so it's probably worth fixing this now and perhaps coming up with some sort of test that will automatically catch these sorts of discrepancies in the future.

mypy.strconv.StrConv also seems to have similar issues, though it's probably even less of a priority. I haven't really checked the other visitors, so I don't know if they're similarly desynched.

(I'm filing this issue to make sure I don't forget about it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringChanging mypy's internals

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions