How to configure Visual Studio Code to recognize external stub files for Python development?

I’m developing a Python plugin that uses a specific external library. I have the following setup:

  • I’m using Visual Studio Code as my IDE
  • I have access to the stub files (.pyi) for the library I’m using
  • The library is not installed in my development environment, as it will be available in the runtime environment where my plugin will be executed

Currently, Visual Studio Code is showing error messages for objects from this library, marking them as unknown, even though they exist in the library.

Is there a config file where I can tell VS Code to search for the definition of the objects from the library in the directory of the stub files? If yes how can I edit them,

I tried to modifiy the settings. under .vscode in my project root. (You can do that in file, preferrence, setting)

According to https://code.visualstudio.com/docs/python/settings-reference , I have to ovewrite stubPath and set languageServer to Default or Pylance

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"python.analysis.stubPath": "C:\Program Files\Stubs",
"python.languageServer": "Pylance",
}
</code>
<code>{ "python.analysis.stubPath": "C:\Program Files\Stubs", "python.languageServer": "Pylance", } </code>
{
    "python.analysis.stubPath": "C:\Program Files\Stubs",
    "python.languageServer": "Pylance",

}

But noting happends

I tried with other settings like “extapath” but it didn t work either

3

This solution works but this is not optimal

I can copy paste the .py in a directory in the project like that

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>root
+-- stub_directory
+-- mycode
</code>
<code>root +-- stub_directory +-- mycode </code>
root
+-- stub_directory
+-- mycode

it work but I have to write

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> import sub_directory.importedfile
</code>
<code> import sub_directory.importedfile </code>
 import sub_directory.importedfile 

instead of

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> import importedfile
</code>
<code> import importedfile </code>
 import importedfile

I can copy paste all pyi files directly in the root but that make the project more difficulty to read.

A best solution would be to add a configuration file somewhere in the project that enable pylance (a visual studio extension ) to enable visual studio to access the pyi files

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật