← 返回首页
`__annotations__` are not inherited in 3.10 while they are in 3.8 · Issue #99535 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

__annotations__ are not inherited in 3.10 while they are in 3.8 #99535

New issue
New issue

Description

Bug report

Python 3.8.13 inherits annotations from a subclass:

Python 3.8.13 (default, Oct 19 2022, 17:54:22) [Clang 12.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... x: int ... >>> class B(A): ... pass ... >>> print(A.__annotations__) {'x': <class 'int'>} >>> print(B.__annotations__) {'x': <class 'int'>} >>> print(B.__dict__) {'__module__': '__main__', '__doc__': None}

Python 3.10.8 does not:

Python 3.10.8 (main, Nov 4 2022, 08:45:18) [Clang 12.0.0 ] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... x: int ... >>> class B(A): ... pass ... >>> print(A.__annotations__) {'x': <class 'int'>} >>> print(B.__annotations__) {} >>> print(B.__dict__) {'__module__': '__main__', '__doc__': None, '__annotations__': {}}

Can't find anything related to this in the changelogs, release notes, stackoverflow etc. Is this known/expected behaviour?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.