Maturin imports not resolved #8145
Replies: 9 comments
-
This is unlikely to be a bug in pyright, but I can help you try to figure out a solution. I'll need additional information. First, is this the maturin 1.6.0 library in pypi (i.e. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply Yes, this is the maturin from pypi. My project is titled for a code snippet: import pytest
from anyon_braiding_simulator import Anyon, IsingTopoCharge
def test_anyon():
anyon = Anyon('thisisatest', IsingTopoCharge.Psi, (1, 1))
assert anyon.name == 'thisisatest'
assert anyon.charge == IsingTopoCharge.Psi
assert anyon.position == (1, 1) This is a simple test file I have. The code runs fine, but autocomplete is broken for Anyon/IsingTopoCharge, and the same error is listed as my initial post. My project structure is identical to the mixed layout if that helps with configuring the |
Beta Was this translation helpful? Give feedback.
-
OK, so these are generated bindings. I obviously don't have access to your Is the |
Beta Was this translation helpful? Give feedback.
-
Here's the project The module is installed within my venv's site packages. It has an |
Beta Was this translation helpful? Give feedback.
-
Can you provide step-by-step instructions for reproducing your problem? Assume I know nothing about the |
Beta Was this translation helpful? Give feedback.
-
Sorry, I should've given more info about using I'll be more or less paraphrasing this, so feel free to read it if my explanation is insufficient. After installing The main project layout is structured to have It may be important to note that in the However, pyright can't seem to find the import paths for the packages. Notably, pyright gets confused by the name Hopefully this helps for figuring out a solution. I'm rather new to |
Beta Was this translation helpful? Give feedback.
-
I'm looking for a specific set of command-line instructions, something like:
I'm going to convert this from a bug report to a discussion topic since this is unlikely to be a bug in pyright and likely to be a configuration issue or a problem with the generated bindings. |
Beta Was this translation helpful? Give feedback.
-
First 3 instructions are the same. Then: I am certain this is not an issue with the code because:
I assume this can be fixed with some inclusion for the pyright import path in |
Beta Was this translation helpful? Give feedback.
-
I think this is because Matuin and pyo3 don't generate Once the There is an open issue tracking adding automatic python interface file generation to pyo3. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Pyright fails to import packages from Maturin/PyO3 (Rust bindings for python). I verified that this was a fault of pyright by trying 3 different editors which all rely on the pyright language server (Emacs, Neovim, and Zed). The import works fine using Pylance and the standard python ishell. Other imports within the venv behave normally (i.e. external packages and internal python files).
Code or Screenshots
Pyright (Emacs)
Pylance (VSCode)
VS Code extension or command-line
pyright 1.1.366
Run via pyright-langserver --stdio
Additional
I think this bug is fixable by adding the appropriate file path to a pyproject.toml/pyrightconfig.json, but this should be a default behavior of pyright given that pylance "just works".
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions