Skip to content

mypy should check qualname (and other special dunders) #20821

Open

Description

@A5rocks

Bug Report

Noticed when playing with #20819. When you assign an int to __qualname__, Python raises a TypeError but mypy itself doesn't.

To Reproduce

class X:
    __qualname__ = 5

Expected Behavior

Error.

Actual Behavior

No error.

Your Environment

Reproduced in mypy-play

  • Mypy version used: 1.19.1
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.12

Activity

  1. added a commit that references this issue on Feb 16, 2026
  2. added 2 commits that reference this issue on Apr 13, 2026
    cca0817
    cc69f3f
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