-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Labels
importsModule resolution, site-packages discovery, import-related diagnosticsModule resolution, site-packages discovery, import-related diagnostics
Milestone
Description
Langchain has an __init__.py with the following content
# ruff: noqa: E402
import pytest
# Rewrite assert statements for test suite so that implementations can
# see the full error message from failed asserts.
# https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#assertion-rewriting
modules = [
"chat_models",
"embeddings",
"tools",
]
for module in modules:
pytest.register_assert_rewrite(f"langchain_tests.unit_tests.{module}")
from .chat_models import ChatModelUnitTests
from .embeddings import EmbeddingsUnitTests
from .tools import ToolsUnitTests
__all__ = ["ChatModelUnitTests", "EmbeddingsUnitTests", "ToolsUnitTests"]ty fails to resolve the relative imports chat_models, embeddings and .tools even though those files clearly exist. Pyright seems fine with the import.
The issue seems to be that file_to_module fails because the relative path to the search root (which is the project root) libs/standard-tests/langchain_tests/unit_tests/teswt.py can't be turned into a valid module name because of the standard-tests.
A solution here is to add standard-tests to the search path but having to do this is at least confusing in an LSP setup (where ty should just work out of the box)
msw-kialo, mxmlnkn and adamjstewart
Metadata
Metadata
Assignees
Labels
importsModule resolution, site-packages discovery, import-related diagnosticsModule resolution, site-packages discovery, import-related diagnostics