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.24k stars 1.12k forks source link

Using typeshed stubs instead of dependencies #9574

Open xrmx opened 4 months ago

xrmx commented 4 months ago

Question

Would it be possible (or even make sense) to use to use the stubs from typeshed instead of the real libraries in pylint checks?

import requests

requests.get("https:")

returns

foo.py:3:0: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)

with requests installed but nothing with just types-requests.

Documentation for future user

No idea, it would be nice to have an example in the tutorial using a third party library and explicitly saying you need to install it in order to provide more checks.

Additional context

No response

Pierre-Sassoulas commented 4 months ago

Thank you for the suggestion. I added the need design proposal because I don't know if we should always use the stub if it exists or leave the choice to the user, or how to remove the lib files from the analysis if the stub exists. It feels non trivial :)