Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix callback of throttled/debounced decorated functions with mismatched args #184

Merged
merged 7 commits into from
Aug 17, 2023

Conversation

tlambert03
Copy link
Member

@tlambert03 tlambert03 commented Aug 16, 2023

similar to #183, this fixes calling a qdebounced/qthrottled function with too many arguments

class Emitter(QObject):
    sig = Signal(int, int, int)

@qdebounced
def func(a: int, b: int):
    ...

obj = Emitter()
obj.sig.connect(func)
obj.sig.emit(1, 2, 3)  # currently breaks, too many args

I had to do it manually here (meaning pass func(*args[:max_args])), because of a bug in pyside that prevents proper inspection of callable objects:
https://bugreports.qt.io/browse/PYSIDE-2423

This PR also changes the decorator pattern to return an instance of ThrottledCallable (whereas before it just returned an object that implemented the protocol). I think it makes for a much clearer read

@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.76% ⚠️

Comparison is base (41ea4e8) 86.05% compared to head (aac1d14) 85.29%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   86.05%   85.29%   -0.76%     
==========================================
  Files          36       36              
  Lines        2746     2747       +1     
==========================================
- Hits         2363     2343      -20     
- Misses        383      404      +21     
Files Changed Coverage Δ
src/superqt/utils/_throttler.py 89.62% <100.00%> (+0.40%) ⬆️

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/superqt/utils/_throttler.py Outdated Show resolved Hide resolved
@tlambert03 tlambert03 added the bug Something isn't working label Aug 17, 2023
@tlambert03 tlambert03 merged commit 64dfb43 into pyapp-kit:main Aug 17, 2023
42 checks passed
@tlambert03 tlambert03 deleted the fix-throttled branch August 17, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants