python-trio / flake8-async

Highly opinionated linter for Trio code
https://flake8-async.readthedocs.io
MIT License
17 stars 2 forks source link

Add support for `from ... import ...` and `import ... as ...` #132

Open jakkdl opened 1 year ago

jakkdl commented 1 year ago

Quick GitHub search gives 850 results for from anyio import ... and 230 results for trio. So seems relatively prevalent?

With the addition of utility visitors / type tracking, it's not technically difficult to add support for different imports and make TRIO106 a relic of the past. Just gotta add a visit function for Import / ImportFrom, save all aliases in a dictionary, and then e.g. trio105 can make a lookup in the dict to see if the thing it's analyzing has been aliased.

It's going to require rewriting a bunch of checks to use it though, who currently have hard-coded values tested against ast.unparse or a stack of isinstance checks. So if implemented before libCST it would probably be a bunch of duplicated effort - so if you think it's a good idea I would vote to delay it for now.

Zac-HD commented 1 year ago

Let's do it! Later 😁