microsoft / pyright

Static Type Checker for Python
Other
13.41k stars 1.47k forks source link

Pyright cant seem to find attributes of a package unless i explicitly reference them #9447

Closed CapedBojji closed 1 day ago

CapedBojji commented 1 day ago

Describe the bug Download imgui python and try to use imgui.create_context() it will say that the attribute does not exist

Code or Screenshots Image

if I use imgui.core.create_context() it works. even though the imgui __init__.py exports imgui.core ` VS Code extension or command-line im using neovim lazyvim. I have updated to the latest version using mason

erictraut commented 1 day ago

Pyright is working as designed here, so this isn't a bug.

The imgui library is not written in Python, and it doesn't contain any type stub files that describe its interface to a type checker. Pyright can find attributes that are defined in imgui/__init__.py, but it cannot find attributes that are imported from native libraries compiled from C++. If you want this to work, you'll need to find or create your own stub files that describe the interface. For details, refer to this documentation.

For future bug reports, please provide a minimal code sample in text form. Debugging issues form partial screen shots is often difficult or impossible. Also, if you are reporting issues related to a third-party library like imgui, it's useful to know which version of the library you're using.

CapedBojji commented 1 day ago

Ahh that makes sense sorry