astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.27k stars 1.04k forks source link

Import detection and resolution via Python resolver for pylint #9103

Open pwithams opened 9 months ago

pwithams commented 9 months ago

I'm interested in implementing no-name-in-module (E0611) and import-error (E0401) for pylint (https://github.com/astral-sh/ruff/issues/970).

I think this would handle this issue https://github.com/astral-sh/ruff/issues/6327 but as mentioned in that issue thread it might get a little complex with things like virtual environments.

I've taken a brief look at the resolver but wondering if there has been any other work into this issue before continuing. A couple of my thoughts:

charliermarsh commented 8 months ago

Have you taken a look at the resolver we aded in ruff_python_resolver? It's based off Pyright's implementation.

walsha2 commented 5 months ago

@charliermarsh is the ruff_python_resolver intended to be a solution to E0611? I cant seem to find any documentation on what it is currently being used for.

Sure would be nice to get E0611 and E0401 implemented. I just ran into an edge case where these would have caught a file with some bad imports (as pylint would have), but it was not invoked in any tests so it never got caught - until a user runtime error.

vinitkumar commented 2 weeks ago

@charliermarsh In my opinion it should be implemented as well. We just missed a bug due to faulty import and ruff didn't catch the issue. Would be great to have a compatible implementation in our setup as ruff is our primary linter here.

https://github.com/django-cms/django-cms/issues/7992 We have this new issue because we added this faulty imported while backporting a feature, and this module is not in the 3.11 version of the project. Ruff passed the lint with flying colours where it should have pointed it out.

vinitkumar commented 1 day ago

@MichaReiser Can this be prioritised, please?