Closed jakkdl closed 1 year ago
Approach seems promising, agree that list[whatever]
isn't worth handling but whatever|None
probably is (if easy!). I look forward to seeing where this goes after rebasing 😁
Rebased on top of main (which wasn't trivial since it was forked from an outdated #103 that was later amended - fun stuff!). Will now continue working on it~
I'll refactor it in a different PR as I write the next object sync checker, as this one should work well as a standalone. Ready to merge!
For the future refactored version, one annoying (to lint, it's fortunately rare) pattern is defining a httpx.Client()
as a global variable...
For the future refactored version, one annoying (to lint, it's fortunately rare) pattern is defining a
httpx.Client()
as a global variable...
oh and it should work fine with global variables as long as they're defined in the same file. Will add tests to show that.
I'll make a PR just with these two fixes + another pattern I just realized will be useful:
async def type_assign():
f: TextIOWrapper = ...
f.read()
A first draft at tracking types for file/path/httpx/etc and warning on sync calls. Except this one just does it for
open()
and the variosio.*
types it can return as a start. This and others that build on top of it should finish off #58Branched from on top of #103 - but you can just view the latest commit to see the contents of this one.
Flake8TrioVisitor
.super().register('open', 'io.TextIOWrapper')
in the__init__
io.TextIOWrapper
objects to functions, but that's going to be much more common with Path and httpx objects, so I implemented it for this as well just to show the logic.Optional[Path]
andPath|None
will be done.list[Path]
and similar cases can be done if it makes sense but I don't think will be common of any of the types we care about.