Skip to content

Regression related to forward reference and nested classes #18988

Closed
@JukkaL

Description

@JukkaL

This example started generating a false positive about an undefined name (simplified from a real-world generated protobuf stubs):

from typing import NewType

class W[T]: pass

class R:
    class M(W[Action.V], type):  # Name "Action.V" is not defined
        FOO = R.Action.V(0)
    class Action(metaclass=M):
        V = NewType('V', int)

class Action:
    pass

This was a side effect of #18625.

There may be some confusion between R.Action and Action classes.

This looks like a release blocker. This is happening in generated protobuf stubs code which can't be edited easily.

If this is non-trivial to fix, we could temporarily revert the original PR until a fix is available.

cc @ilevkivskyi as the author of the above PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions