Skip to content

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

@A5rocks

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

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