Repository navigation
trio232 now also handles annotated assignments, and added lots of tests - #111
Conversation
76f2c2a to
985f9a2
Compare
| # there might be non-sync calls on TextIOWrappers? - but it will currently trigger | ||
| # on all calls | ||
| f.anything() # TRIO232: 4, 'anything', 'f' |
There was a problem hiding this comment.
Hmm, this is an interesting point... looking at the IOBase docs there are some sync methods that are still fine even in an async context, e.g. .seekable(), .tell(), .isatty(), etc. (though don't trust my quick skim on the details!).
We might therefore want to further restrict this to a blocklist of known-slow-IO methods, e.g. .read(), .readline(), .seek(), etc. That'd be a future PR though.
There was a problem hiding this comment.
I'm pretty sure open&close are still no-go though, so only way to trigger this would be opening a file in a sync context, sending around the TextIOWrapper as a parameter inside your async stuff, and then close it once back in a sync context. Which seems like a huge stretch if the only thing you care about is seekable/tell/isatty.
But this might definitely be much more relevant with other objects.
There was a problem hiding this comment.
Fair enough, and I definitely meant the "might"! I agree that this doesn't seem like it would be much of an improvement in practice, so let's not bother.
Any one of these unhandled cases probably isn't too bad to handle - but to handle all of them would end up making this a pretty complex check. See #110
But if you think any in particular is a common pattern, I can implement that.