Improved static typing in dash.callback#3746
Improved static typing in dash.callback#3746odorikakeru wants to merge 10 commits intoplotly:devfrom
Conversation
…allback_typed did. Update: Rewrote tests to match above change.
…es AI generated code)
|
This is looking good. The new typing test file is not running on ci, the command needs to be adapted here: dash/.github/workflows/testing.yml Line 139 in bf5a329 Also need to run |
Fix: import order failing pylint
|
Thanks for the pointers. I made a couple of small changes. It seems that the linter didn't like my sys.version check in the imports, I took it out and replaced it with a try-except (I know this is more Pythonic, but I'm old fashioned and usually don't like letting expected behaviour raise errors). The advantage is we don't need to import sys anymore. CircleCI is failing on black, but I'm not sure if that's unrelated. |
Black is the Python formatter, just need to run |
|
Thank you. I am aware of black. When I was running black locally under Windows I wasn't seeing any problems, which was the source of the confusion. |
Yes, it's unrelated, the new github ci shows all good but unrelated percy error. The code looks good, I'll check it out and try some type later this week. |
This PR improves static typing for the callback decorator by preserving wrapped function signatures in the callback decorator type contract.
Based on this conversation thread: [Feature Request] A "@dash.typed_callback" that plays more nicely with MyPy than "@dash.callback" #3691 - The decision was made to not implement
@dash.typed_callbackand instead update@dash.callbackbased on feedback.Compliance tests added (not included in integration test directory as type hints don't affect run time behaviour).
DISCLOSURE: Testing code was written/edited with AI assistance.
Contributor Checklist
optionals
CHANGELOG.md