Skip to content

gh-144190: Clarify get_type_hints() instance behavior in docs#144831

Merged
hugovk merged 1 commit intopython:mainfrom
iamrajhans:gh-144190-get-type-hints-docs
Feb 26, 2026
Merged

gh-144190: Clarify get_type_hints() instance behavior in docs#144831
hugovk merged 1 commit intopython:mainfrom
iamrajhans:gh-144190-get-type-hints-docs

Conversation

@iamrajhans
Copy link
Contributor

@iamrajhans iamrajhans commented Feb 15, 2026

Summary

Document typing.get_type_hints() behavior for instance objects in Python 3.14+.

  • Clarify that get_type_hints() is intended for modules, classes, and callables.
  • Add an explicit note that calling get_type_hints() on instances is not supported.
  • Recommend get_type_hints(type(obj)) for instance use cases.
  • Add a versionchanged:: 3.14 note explaining that instance support in earlier versions was undocumented behavior.

Why

Issue #144190 reported a regression when calling get_type_hints(self) in a dataclass __init__.
Core-dev discussion confirmed this is intentional in 3.14 and should be documented.

Testing

Docs-only change; no runtime behavior changed.


📚 Documentation preview 📚: https://cpython-previews--144831.org.readthedocs.build/

@JelleZijlstra JelleZijlstra added the needs backport to 3.14 bugs and security fixes label Feb 15, 2026
@hugovk hugovk merged commit e234662 into python:main Feb 26, 2026
42 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Feb 26, 2026
@miss-islington-app
Copy link

Thanks @iamrajhans for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 26, 2026
…ythonGH-144831)

(cherry picked from commit e234662)

Co-authored-by: Rajhans Jadhao <rajhans.jadhao@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Feb 26, 2026

GH-145258 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Feb 26, 2026
hugovk pushed a commit that referenced this pull request Feb 26, 2026
…H-144831) (#145258)

Co-authored-by: Rajhans Jadhao <rajhans.jadhao@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants