Skip to content

mypy doesn't catch inheritance of outer class #18393

Open

Description

@injust

Bug Report

Inheriting from an outer class raises NameError at runtime, but mypy doesn't catch this.

To Reproduce

class Foo:
    class Bar(Foo):
        pass

Expected Behavior

Actual Behavior

Success: no issues found in 1 source file

Your Environment

  • Mypy version used: 1.14.0
  • Python version used: 3.13

Activity

  1. ahmedkhan1 commented on Oct 6, 2026

    @ahmedkhan1

    Fixed in #22125. The semantic analyzer now reports an undefined-name error when a nested class directly inherits from its still-executing enclosing class, matching CPython's runtime NameError. The regression, self-check, lint, mypy-primer, and full CI matrix are green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctly

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions