pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

Update doc for import discovery and qualified module names #9949

Open akamat10 opened 1 month ago

akamat10 commented 1 month ago

Type of Changes

Type
:scroll: Docs

Description

Refs #9915

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.80%. Comparing base (4c5393f) to head (e31ad17). Report is 1 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pylint-dev/pylint/pull/9949/graphs/tree.svg?width=650&height=150&src=pr&token=ZETEzayrfk&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev)](https://app.codecov.io/gh/pylint-dev/pylint/pull/9949?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev) ```diff @@ Coverage Diff @@ ## main #9949 +/- ## ======================================= Coverage 95.80% 95.80% ======================================= Files 174 174 Lines 18940 18940 ======================================= Hits 18146 18146 Misses 794 794 ```
akamat10 commented 1 month ago

Don't think changelog needs to be updated for docs based on my understanding.

akamat10 commented 1 month ago

Thank you for going through this. It does require reading through the code :) to know it is correct. Mypy docs for reference where they describe their import discovery. The second option ie default in the doc is very similar to what pylint does if source-roots isn't specified. https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules

Personally I think something like this ought to be in the user guide and leaving it out makes it difficult to understand what is going on. The user may not know where the code is where this is happening. If the logic changes, we should update the doc. I am ok with documenting in the code that the doc should change to reflect it.

Is another way to do import discovery and work with qualified module name is simpler and make more sense to you @akamat10 ? If so maybe we could change to it directly.

I assume you mean changing the current logic, right? I think source-root option comes closest in being clean and being able to control to make it to make it similar to how Python works. I have proposed an alteration in #9955 to simplify it. I would still document after changing the behavior so that the user knows.