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 KI protection decorator #2781

Merged
merged 8 commits into from
Sep 6, 2023

Conversation

A5rocks
Copy link
Contributor

@A5rocks A5rocks commented Aug 31, 2023

This should fix the trio.Lock issue in #2775.

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #2781 (2933c6d) into master (1c15500) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2781   +/-   ##
=======================================
  Coverage   98.94%   98.94%           
=======================================
  Files         113      113           
  Lines       16919    16920    +1     
  Branches     3050     3050           
=======================================
+ Hits        16741    16742    +1     
  Misses        123      123           
  Partials       55       55           
Files Changed Coverage Δ
trio/_core/_ki.py 100.00% <100.00%> (ø)

@apollo13
Copy link
Contributor

apollo13 commented Sep 1, 2023

Can confirm that it fixes my Lock issue.

Copy link
Contributor

@TeamSpen210 TeamSpen210 left a comment

Choose a reason for hiding this comment

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

Makes sense as a solution, I had a little difficulty too when doing this originally. Actually though, it'd be better to use a typevar with bound=Callable, instead of ParamSpec - in that case, the checker can preserve the entire function type, including things like overloads.

@TeamSpen210 TeamSpen210 added the typing Adding static types to trio's interface label Sep 1, 2023
Copy link
Member

@jakkdl jakkdl left a comment

Choose a reason for hiding this comment

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

though if teamspen's suggestion of a typevar works that sounds like it would be even better

@A5rocks
Copy link
Contributor Author

A5rocks commented Sep 3, 2023

Makes sense as a solution, I had a little difficulty too when doing this originally. Actually though, it'd be better to use a typevar with bound=Callable, instead of ParamSpec - in that case, the checker can preserve the entire function type, including things like overloads.

I'm not entirely sure this is possible due to use using *args: P.args, etc. inside. It might be possible though? And that might be better external-facing behavior so probably worth a # type: ignore if CI running atm says it doesn't work.

@CoolCat467 CoolCat467 merged commit 4a84041 into python-trio:master Sep 6, 2023
@A5rocks A5rocks deleted the fix-ki-enabled-type branch September 6, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typing Adding static types to trio's interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants