Use `annotationlib` to simplify `test_official`
Author: harshil21Created Jun 9, 2026Updated Jun 9, 2026
Labels🛠 refactor
What kind of feature are you missing? Where do you notice a shortcoming of PTB?
Starting from Python 3.14, we can use annotationlib to refactor test_official to more properly work with annotations, specially forward references.
Describe the solution you'd like
Using annotationlib means we will require >=3.14 to run test official. IISC, annotationlib also resolves nested forward references, which is great for our use case.
Describe alternatives you've considered
Do patch work on existing codebase, but that's not a healthy practice.
Additional context
This recently came up in the #5259 PR where internal python API was changed, making it annoying to run the test official on 3.15.
Source: python-telegram-bot/python-telegram-bot