Follow-up to #8540, which turned on `PLC0415` (import-outside-top-level) for checkpoint-postgres and checkpoint-sqlite. This does the remaining six packages: checkpoint, checkpoint-conformance, langgraph, prebuilt, cli, sdk-py. Scoped to tests, per @sydney-runkle's call on #8540: library code is exempted with `per-file-ignores`, since it still has deferred imports nobody has reviewed and mixing that in would make this hard to read. ## What changed Function-level imports across 56 test files moved to module level. Nine could not move and carry an explicit `# noqa: PLC0415` with a reason: | File | Why it stays local | |---|---| | `libs/langgraph/tests/test_deprecation.py` (4) | the import has to run inside `pytest.warns` for the warning to be observed | | `libs/langgraph/tests/test_serde_allowlist.py` | try/except guard, skips when langchain_core is absent | | `libs/langgraph/tests/test_delta_channel_benchmark.py` | optional psycopg probe | | `libs/checkpoint/tests/test_conformance_delta.py` (3) | protected by a module-level `pytest.importorskip`; hoisting past the guard turns a skip into a collection error | That last one is the trap: an import moved above `pytest.importorskip` silently defeats the guard. I hit it locally and it turned the skip into a `ModuleNotFoundError` at collection. Every file with an `importorskip` or `except ImportError` was checked by hand for this. ## Verification `make lint` and `make test` in each of the six: | Package | Tests | |---|---| | checkpoint | 156 passed, 17 skipped | | checkpoint-conformance | 1 passed | | langgraph | 1968 passed, 4 skipped | | prebuilt | 284 passed | | cli | 336 passed | | sdk-py | 493 passed | Also confirmed the rule actually fires: a throwaway test file with a function-level import is flagged in all six packages, and the source exemption holds.
LangGraph CLI
To help you ship LangGraph apps to production faster, check out LangSmith. LangSmith is a unified developer platform for building, testing, and monitoring LLM applications.
Quick Install
uv add langgraph-cli
🤔 What is this?
The LangGraph CLI is the official command-line interface for LangGraph. It provides tools to create, develop, build, and run LangGraph applications locally or in Docker.
📖 Documentation
For full documentation, see the LangGraph CLI reference. For conceptual guides and tutorials, see the LangGraph Docs.
For development mode with hot reloading:
uv add "langgraph-cli[inmem]"
Commands
langgraph new 🌱
Create a new LangGraph project from a template.
langgraph new [PATH] --template TEMPLATE_NAME
langgraph dev 🏃♀️
Run LangGraph API server in development mode with hot reloading.
langgraph dev [OPTIONS]
--host TEXT Host to bind to (default: 127.0.0.1)
--port INTEGER Port to bind to (default: 2024)
--no-reload Disable auto-reload
--debug-port INTEGER Enable remote debugging
--no-browser Skip opening browser window
-c, --config FILE Config file path (default: langgraph.json)
langgraph up 🚀
Launch LangGraph API server in Docker.
langgraph up [OPTIONS]
-p, --port INTEGER Port to expose (default: 8123)
--wait Wait for services to start
--watch Restart on file changes
--verbose Show detailed logs
-c, --config FILE Config file path
-d, --docker-compose Additional services file
langgraph build
Build a Docker image for your LangGraph application.
langgraph build -t IMAGE_TAG [OPTIONS]
--platform TEXT Target platforms (e.g., linux/amd64,linux/arm64)
--pull / --no-pull Use latest/local base image
-c, --config FILE Config file path
langgraph dockerfile
Generate a Dockerfile for custom deployments.
langgraph dockerfile SAVE_PATH [OPTIONS]
-c, --config FILE Config file path
Configuration
The CLI uses a langgraph.json configuration file with these key settings:
{
"dependencies": ["langchain_openai", "./your_package"],
"graphs": {
"my_graph": "./your_package/file.py:graph"
},
"env": "./.env",
"python_version": "3.11",
"pip_config_file": "./pip.conf",
"dockerfile_lines": []
}
See the full documentation for detailed configuration options.
Development
To develop the CLI itself:
- Clone the repository
- Navigate to the CLI directory:
cd libs/cli - Install development dependencies:
uv sync - Make your changes to the CLI code
- Test your changes:
# Run CLI commands directly
uv run langgraph --help
# Or use the examples
cd examples
uv sync
uv run langgraph dev # or other commands
📕 Releases & Versioning
See our Releases and Versioning policies.
💁 Contributing
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the Contributing Guide.