Skip to content

fix(propertyanimation): resolve postponed annotations before casting - #655

Merged
ceccopierangiolieugenio merged 1 commit into
ceccopierangiolieugenio:mainfrom
Sanjays2402:fix/property-animation-postponed-annotations
Jul 29, 2026
Merged

fix(propertyanimation): resolve postponed annotations before casting#655
ceccopierangiolieugenio merged 1 commit into
ceccopierangiolieugenio:mainfrom
Sanjays2402:fix/property-animation-postponed-annotations

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #493

TTkPropertyAnimation builds its cast list from getfullargspec().annotations. In modules using from __future__ import annotations (PEP 563) those annotations are plain strings, so the cast called a str and raised TypeError: 'str' object is not callable. TTkWidget is such a module, which is why TTkPropertyAnimation(None, winTe.move) crashed 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 skipped.

Added tests/pytest/test_009_property_animation.py: the two postponed-annotation cases fail with the reported TypeError without the fix and pass with it; the full tests/pytest suite is green (1071 passed).

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
Copilot AI review requested due to automatic review settings July 25, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 to getfullargspec().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
ceccopierangiolieugenio merged commit 01a84a9 into ceccopierangiolieugenio:main Jul 29, 2026
6 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TTkPropertyAnimation crash

3 participants