Skip to content

The agent engineering platform.

style: fix some ruff noqa (#35321)

Christophe Bornet6a6ef8caad20
diff --git a/libs/core/pyproject.toml b/libs/core/pyproject.toml
index d4772a0818..b297758c4b 100644
--- a/libs/core/pyproject.toml
+++ b/libs/core/pyproject.toml
@@ -133,7 +133,7 @@ ignore-var-parameters = true # ignore missing documentation for *args and **kwa
"langchain_core/sys_info.py" = [ "T201",]
"tests/unit_tests/test_tools.py" = [ "ARG",]
"tests/**" = [ "D1", "PLR2004", "S", "SLF",]
-"scripts/**" = [ "INP", "S",]
+"scripts/**" = [ "INP", "S", "T201",]
[tool.coverage.run]
omit = [ "tests/*",]
diff --git a/libs/core/scripts/check_imports.py b/libs/core/scripts/check_imports.py
index 9e847e1b03..a5936a3a4b 100644
--- a/libs/core/scripts/check_imports.py
+++ b/libs/core/scripts/check_imports.py
@@ -17,8 +17,8 @@ if __name__ == "__main__":
SourceFileLoader(module_name, file).load_module()
except Exception:
has_failure = True
- print(file) # noqa: T201
+ print(file)
traceback.print_exc()
- print() # noqa: T201
+ print()
sys.exit(1 if has_failure else 0)
diff --git a/libs/core/scripts/check_version.py b/libs/core/scripts/check_version.py
index 4e2fb695f4..6f7712a76e 100644
--- a/libs/core/scripts/check_version.py
+++ b/libs/core/scripts/check_version.py
@@ -33,31 +33,31 @@ def main() -> int:
version_path = package_dir / "langchain_core" / "version.py"
if not pyproject_path.exists():
- print(f"Error: {pyproject_path} not found") # noqa: T201
+ print(f"Error: {pyproject_path} not found")
return 1
if not version_path.exists():
- print(f"Error: {version_path} not found") # noqa: T201
+ print(f"Error: {version_path} not found")
return 1
pyproject_version = get_pyproject_version(pyproject_path)
version_py_version = get_version_py_version(version_path)
if pyproject_version is None:
- print("Error: Could not find version in pyproject.toml") # noqa: T201
+ print("Error: Could not find version in pyproject.toml")
return 1
if version_py_version is None:
- print("Error: Could not find VERSION in langchain_core/version.py") # noqa: T201
+ print("Error: Could not find VERSION in langchain_core/version.py")
return 1
if pyproject_version != version_py_version:
- print("Error: Version mismatch detected!") # noqa: T201
- print(f" pyproject.toml: {pyproject_version}") # noqa: T201
- print(f" langchain_core/version.py: {version_py_version}") # noqa: T201
+ print("Error: Version mismatch detected!")
+ print(f" pyproject.toml: {pyproject_version}")
+ print(f" langchain_core/version.py: {version_py_version}")
return 1
- print(f"Version check passed: {pyproject_version}") # noqa: T201
+ print(f"Version check passed: {pyproject_version}")
return 0
diff --git a/libs/langchain_v1/pyproject.toml b/libs/langchain_v1/pyproject.toml
index cfccf4fbe5..78d938874d 100644
--- a/libs/langchain_v1/pyproject.toml
+++ b/libs/langchain_v1/pyproject.toml
@@ -175,7 +175,8 @@ ignore-var-parameters = true # ignore missing documentation for *args and **kwa
]
"scripts/*" = [
- "INP", # Scripts are not in a package
+ "INP", # Scripts are not in a package
+ "T201", # Scripts can print to the console
]
[tool.coverage.run]
diff --git a/libs/langchain_v1/scripts/check_imports.py b/libs/langchain_v1/scripts/check_imports.py
index ebf66aa036..5c0ac03efa 100644
--- a/libs/langchain_v1/scripts/check_imports.py
+++ b/libs/langchain_v1/scripts/check_imports.py
@@ -26,8 +26,8 @@ if __name__ == "__main__":
SourceFileLoader(module_name, file).load_module()
except Exception:
has_failure = True
- print(file) # noqa: T201
+ print(file)
traceback.print_exc()
- print() # noqa: T201
+ print()
sys.exit(1 if has_failure else 0)
diff --git a/libs/langchain_v1/scripts/check_version.py b/libs/langchain_v1/scripts/check_version.py
index 35ab978959..5202e7933e 100644
--- a/libs/langchain_v1/scripts/check_version.py
+++ b/libs/langchain_v1/scripts/check_version.py
@@ -33,31 +33,31 @@ def main() -> int:
init_path = package_dir / "langchain" / "__init__.py"
if not pyproject_path.exists():
- print(f"Error: {pyproject_path} not found") # noqa: T201
+ print(f"Error: {pyproject_path} not found")
return 1
if not init_path.exists():
- print(f"Error: {init_path} not found") # noqa: T201
+ print(f"Error: {init_path} not found")
return 1
pyproject_version = get_pyproject_version(pyproject_path)
init_version = get_init_version(init_path)
if pyproject_version is None:
- print("Error: Could not find version in pyproject.toml") # noqa: T201
+ print("Error: Could not find version in pyproject.toml")
return 1
if init_version is None:
- print("Error: Could not find __version__ in langchain/__init__.py") # noqa: T201
+ print("Error: Could not find __version__ in langchain/__init__.py")
return 1
if pyproject_version != init_version:
- print("Error: Version mismatch detected!") # noqa: T201
- print(f" pyproject.toml: {pyproject_version}") # noqa: T201
- print(f" langchain/__init__.py: {init_version}") # noqa: T201
+ print("Error: Version mismatch detected!")
+ print(f" pyproject.toml: {pyproject_version}")
+ print(f" langchain/__init__.py: {init_version}")
return 1
- print(f"Version check passed: {pyproject_version}") # noqa: T201
+ print(f"Version check passed: {pyproject_version}")
return 0
diff --git a/libs/standard-tests/langchain_tests/integration_tests/__init__.py b/libs/standard-tests/langchain_tests/integration_tests/__init__.py
index 2c1f0a380b..29dee6ef6b 100644
--- a/libs/standard-tests/langchain_tests/integration_tests/__init__.py
+++ b/libs/standard-tests/langchain_tests/integration_tests/__init__.py
@@ -1,6 +1,8 @@
"""Integration tests for LangChain components."""
# ruff: noqa: E402
+import importlib.util
+
import pytest
# Rewrite assert statements for test suite so that implementations can
@@ -19,13 +21,8 @@ modules = [
for module in modules:
pytest.register_assert_rewrite(f"langchain_tests.integration_tests.{module}")
-_HAS_DEEPAGENTS = False
-try:
- import deepagents # noqa: F401
-except ImportError:
- _HAS_DEEPAGENTS = False
-else:
- _HAS_DEEPAGENTS = True
+_HAS_DEEPAGENTS = importlib.util.find_spec("deepagents") is not None
+if _HAS_DEEPAGENTS:
pytest.register_assert_rewrite("langchain_tests.integration_tests.sandboxes")
from langchain_tests.integration_tests.base_store import (