microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.72k stars 766 forks source link

Pyright/Pylance inconsistency: Unknown import symbol sklearn #6410

Closed einarwar closed 1 month ago

einarwar commented 1 month ago

Environment data

rchiodo commented 1 month ago

Thanks for the issue. This is because our bundled type stubs don't match your scikit-learn version. The stubs here need to be updated: https://github.com/microsoft/python-type-stubs/tree/main/stubs/sklearn

einarwar commented 1 month ago

Thanks for the quick response. Should i raise an issue in that repo as well?

rchiodo commented 1 month ago

Yeah it wouldn't hurt. Somebody might have the time to update those stubs.

einarwar commented 1 month ago

Took the matter into my own hands: https://github.com/microsoft/python-type-stubs/pull/317

One question though: Is this expected behaviour by pylance? I have read about the differences between pylance and pyright, e.g useLibraryCodeForTypes. I tried with this setting both enabled and disabled, without any effect. I would have thought that the default behaviour regardless would be to inspect the package if it was installed. However, scikit-learn does not have a py.typed file, which might have an effect here

debonte commented 1 month ago

Took the matter into my own hands: microsoft/python-type-stubs#317

Thanks @einarwar! I just merged your PR. It will show up in next week's prerelease build.

useLibraryCodeForTypes. I tried with this setting both enabled and disabled, without any effect.

useLibraryCodeForType only comes into play when no stubs are found. You can read more about our resolution order here.

StellaHuang95 commented 1 month ago

This issue has been fixed in prerelease version 2024.9.102, which we've just released. You can find the changelog here: CHANGELOG.md