Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

get_type_hints fails fordataclass in 3.14 #144190

Closed
Labels
3.14bugs and security fixes3.15new features, bugs and security fixesdocsDocumentation in the Doc dirtopic-typing
@bfrandeen

Description

@bfrandeen

Bug report

Bug description:

This code works in 3.13, but fails in 3.14:

fromdataclassesimportdataclassfromtypingimportget_type_hints@dataclassclassMyHintedClass:my_attr:int=1def__init__(self):self.hints=get_type_hints(self)my_class=MyHintedClass()print(my_class.hints)

Failure in 3.14:

~\py\pybug: uv run --python=3.14 python main.py                                                                                                                                                                                                     Traceback (most recent call last):  File"C:\Users\bfrandeen\py\pybug\main.py", line 13,in<module>    my_class =MyHintedClass()  File"C:\Users\bfrandeen\py\pybug\main.py", line 10,in __init__    self.hints = get_type_hints(self)~~~~~~~~~~~~~~^^^^^^  File"C:\Users\bfrandeen\AppData\Roaming\uv\python\cpython-3.14.2-windows-x86_64-none\Lib\typing.py", line 2401,in get_type_hints    hints = _lazy_annotationlib.get_annotations(obj, format=format)  File"C:\Users\bfrandeen\AppData\Roaming\uv\python\cpython-3.14.2-windows-x86_64-none\Lib\annotationlib.py", line 996,in get_annotations    raise TypeError(f"{obj!r} does not have annotations")TypeError: MyHintedClass(my_attr=1) does not have annotations

Works in older versions:

~\py\pybug: uv run --python=3.13 python main.pyUsing CPython 3.13.2Removed virtual environment at: .venvCreating virtual environment at: .venvInstalled 6 packagesin 190ms{'my_attr':<class'int'>}

CPython versions tested on:

3.14, 3.13

Operating systems tested on:

Windows, Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesdocsDocumentation in the Doc dirtopic-typing

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp