Skip to content

Unhelpful error message for A.__annotate__('x') #135564

Closed
@PierreQuentel

Description

@PierreQuentel

Bug report

Bug description:

Python 3.14.0b2 (tags/v3.14.0b2:12d3f88, May 26 2025, 13:55:44) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class A:
...     x: int
...
>>> A.__annotate__('x')
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    A.__annotate__('x')
    ~~~~~~~~~~~~~~^^^^^
  File "<python-input-0>", line 1, in __annotate__
    class A:

TypeError: '>' not supported between instances of 'str' and 'int'
>>>

The message should be something like

TypeError: __annotate__() argument must be int, not str

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions