fix(propertyanimation): resolve postponed annotations before casting - #655
Merged
ceccopierangiolieugenio merged 1 commit intoJul 29, 2026
Conversation
TTkPropertyAnimation builds its cast list from getfullargspec().annotations. Modules using "from __future__ import annotations" (PEP 563) keep those annotations as strings, so the cast called a str and raised "TypeError: 'str' object is not callable". TTkWidget lives in such a module, so any animation targeting for example TTkWidget.move crashed on start(), as reported in demo/showcase/animation.01.py. Annotations are now resolved with typing.get_type_hints() (falling back to the raw spec annotations) and non-callable entries are ignored. Closes ceccopierangiolieugenio#493
There was a problem hiding this comment.
✅ Ready to approve
The change is localized, adds regression coverage for the reported crash, and includes safe fallback behavior if type-hint resolution fails.
Note: this review does not count toward required approvals for merging.
Pull request overview
This PR fixes a crash in TTkPropertyAnimation when callbacks come from modules using postponed evaluation of annotations (from __future__ import annotations), by resolving annotations to actual types before building the cast list.
Changes:
- Resolve callback annotations via
typing.get_type_hints()with a safe fallback togetfullargspec().annotations. - Skip non-callable annotation entries to avoid attempting invalid casts.
- Add regression tests covering bound-method and property-name callbacks under postponed annotations, plus a lambda no-cast case.
File summaries
| File | Description |
|---|---|
libs/pyTermTk/TermTk/TTkCore/propertyanimation.py |
Resolves postponed annotations before casting and avoids calling non-callable “types”. |
tests/pytest/test_009_property_animation.py |
Adds regression tests ensuring _cast works with postponed-annotation methods and remains a no-op for lambdas. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Low
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
ceccopierangiolieugenio
approved these changes
Jul 29, 2026
ceccopierangiolieugenio
merged commit Jul 29, 2026
01a84a9
into
ceccopierangiolieugenio:main
6 of 11 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #493
TTkPropertyAnimationbuilds its cast list fromgetfullargspec().annotations. In modules usingfrom __future__ import annotations(PEP 563) those annotations are plain strings, so the cast called astrand raisedTypeError: 'str' object is not callable.TTkWidgetis such a module, which is whyTTkPropertyAnimation(None, winTe.move)crashed indemo/showcase/animation.01.py.Annotations are now resolved with
typing.get_type_hints()(falling back to the raw spec annotations) and non-callable entries are skipped.Added
tests/pytest/test_009_property_animation.py: the two postponed-annotation cases fail with the reportedTypeErrorwithout the fix and pass with it; the fulltests/pytestsuite is green (1071 passed).