microsoft/python-language-server

Platform-Specific Imports - Ignore 'Unresolved Import' for specific package

jaymegordo opened this issue · 3 comments

I have some files which have imports for either mac or windows.

Is there a way to disable the 'unresolved import' warning for specific package imports?

Screen Shot 2020-07-02 at 10 53 24

something like:
"python.languageServer.disabledImportWarnings": ["win32com", "aeosa"]

One option is to replace the f.is_mac() and f.is_win() calls with sys.platform == 'darwin' and sys.platform == 'win32' respectively. Pylance will recognize these built-in conditional checks and analyze only the portions of the code that apply to your current platform.

If you add # noqa to the line, does the message disappear?

@erictraut @jakebailey Both solutions work, very helpful thanks!