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 signature inspection on debounced/throttled, update typing and wrapped #228

Merged
merged 5 commits into from
Aug 14, 2023

Conversation

tlambert03
Copy link
Member

@tlambert03 tlambert03 commented Aug 14, 2023

in mypyc's words: "inspect.signature chokes on compiled functions"... which is a bummer for throttled/debounced if we're going to use them as callbacks (which is their main goal).

This PR fixes napari/napari#6149 (comment) by telling inspect.signature how to get to the wrapped function. I think it should be good enough, but if more problems arise, we can just skip mypyc compilation on these modules.

cc @andy-sweet

edit: i just decided not to compile that module for now.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 14, 2023

CodSpeed Performance Report

Merging #228 will not alter performance

Comparing tlambert03:debounced-sig (bfd6888) with main (980d0a5)

Summary

✅ 66 untouched benchmarks

@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (980d0a5) 100.00% compared to head (bfd6888) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #228   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         1809      1829   +20     
=========================================
+ Hits          1809      1829   +20     
Files Changed Coverage Δ
src/psygnal/_throttler.py 100.00% <100.00%> (ø)

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

Copy link
Member

@andy-sweet andy-sweet left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@@ -27,9 +30,18 @@ def __init__(
self._args: tuple[Any, ...] = ()
self._kwargs: dict[str, Any] = {}

# this mimics what functools.wraps does, but avoids __dict__ usage and other
# things that won't work with mypyc... HOWEVER, most of these dynamic
Copy link
Member

Choose a reason for hiding this comment

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

By won't work, I guess you mean that mypyc will just ignore these? But won't error?

Copy link
Member Author

Choose a reason for hiding this comment

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

correct. __doc__ will be None on mypyc... (i.e. it won't update the doc on the instance itself)

tests/test_throttler.py Outdated Show resolved Hide resolved
@tlambert03 tlambert03 changed the title fix: fix signature inspection on debounced/throttled fix: fix signature inspection on debounced/throttled, update typing and wrapped Aug 14, 2023
@tlambert03 tlambert03 enabled auto-merge (squash) August 14, 2023 23:36
@tlambert03 tlambert03 merged commit af20a70 into pyapp-kit:main Aug 14, 2023
27 checks passed
@tlambert03 tlambert03 deleted the debounced-sig branch August 14, 2023 23:40
@tlambert03 tlambert03 added the bug Something isn't working label Aug 14, 2023
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.

Connecting a debounced callback to an EventedModel's EmitterGroup errors
2 participants