Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import nox |
| 2 | |
| 3 | from nox.sessions import Session |
| 4 | |
| 5 | nox.options.default_venv_backend = "uv" |
| 6 | |
| 7 | # Modules for both ruff and mypy |
| 8 | modules_for_mypy = [ |
| 9 | "composio/", |
| 10 | "providers/", |
| 11 | "tests/", |
| 12 | "scripts/", |
| 13 | ] |
| 14 | |
| 15 | # Modules for ruff only (includes examples) |
| 16 | modules_for_ruff = [ |
| 17 | "composio/", |
| 18 | "providers/", |
| 19 | "tests/", |
| 20 | "examples/", |
| 21 | "scripts/", |
| 22 | ] |
| 23 | |
| 24 | # Type stubs and provider libraries installed solely so mypy can resolve |
| 25 | # imports across `providers/` and `tests/`. These can't live in the locked |
| 26 | # `dev` dependency group: the provider libraries (crewai, langchain, |
| 27 | # llama-index, ...) would drag conflicting transitive deps into the root |
| 28 | # resolution. Shared test/lint tooling (ruff, pytest, fastapi, semver, |
| 29 | # langchain-openai) is sourced from the `dev` group in pyproject.toml via |
| 30 | # `--group dev`, so every package is declared in exactly one place. |
| 31 | type_stubs = [ |
| 32 | "types-requests==2.33.0.20260906", |
| 33 | "types-protobuf==7.35.1.20260906", |
| 34 | "types-jsonschema==4.26.0.20260518", |
| 35 | "anthropic==0.120.0", |
| 36 | # Keep this aligned with the CrewAI provider dependency metadata. |
| 37 | "crewai==1.15.42", |
| 38 | "langchain==1.3.14", |
| 39 | "langgraph==1.2.9", |
| 40 | "llama-index==0.14.23", |
| 41 | "openai-agents==0.18.3", |
| 42 | "google-cloud-aiplatform==1.162.0", |
| 43 | # Keep this inside the TypeSafe provider's `>=0.6.0,<0.7.0` range. |
| 44 | "typesafe-sdk==0.6.0", |
| 45 | ] |
| 46 | |
| 47 | mypy = "mypy==2.3.1" |
| 48 | |
| 49 | ruff = [ |
| 50 | "ruff", |
| 51 | "--config", |
| 52 | "config/ruff.toml", |
| 53 | ] |
| 54 | |
| 55 | |
| 56 | @nox.session |
| 57 | def fmt(session: Session): |
| 58 | """Format code""" |
| 59 | session.install("--group", "dev") |
| 60 | session.run("ruff", "check", "--select", "I", "--fix", *modules_for_ruff) |
| 61 | session.run("ruff", "format", *modules_for_ruff) |
| 62 | |
| 63 | |
| 64 | @nox.session |
| 65 | def chk(session: Session): |
| 66 | """Check for linter and type issues""" |
| 67 | session.install(".", "--group", "dev", mypy, *type_stubs) |
| 68 | session.run(*ruff, "check", *modules_for_ruff) |
| 69 | for module in modules_for_mypy: |
| 70 | session.run("mypy", "--config-file", "config/mypy.ini", module) |
| 71 | |
| 72 | |
| 73 | @nox.session |
| 74 | def fix(session: Session): |
| 75 | """Fix linter issues""" |
| 76 | session.install("--group", "dev") |
| 77 | session.run(*ruff, "check", "--fix", *modules_for_ruff) |
| 78 | |
| 79 | |
| 80 | @nox.session |
| 81 | def chk_examples(session: Session): |
| 82 | """Type-check example scripts against the SDK surface. |
| 83 | |
| 84 | Examples run one mypy invocation per file: duplicate basenames |
| 85 | (examples/tools.py, examples/tool_router/tools.py) collide as module |
| 86 | names inside a single run. Third-party agent frameworks stay |
| 87 | unresolved on purpose; the check targets composio API usage. |
| 88 | """ |
| 89 | from pathlib import Path |
| 90 | |
| 91 | session.install(".", "--group", "dev", mypy, *type_stubs) |
| 92 | for path in sorted(Path("examples").rglob("*.py")): |
| 93 | session.run( |
| 94 | "mypy", |
| 95 | "--config-file", |
| 96 | "config/mypy.ini", |
| 97 | "--ignore-missing-imports", |
| 98 | # Examples wrap their bodies in unannotated main()s; without this |
| 99 | # mypy skips those bodies entirely and the gate checks almost nothing. |
| 100 | "--check-untyped-defs", |
| 101 | str(path), |
| 102 | ) |
| 103 | |
| 104 | |
| 105 | # Providers the `tst` environment installs that the free-form argument matrix |
| 106 | # in tests/test_provider_argument_serialization.py covers. |
| 107 | TST_MATRIX_PROVIDERS = ( |
| 108 | "crewai", |
| 109 | "langchain", |
| 110 | "langgraph", |
| 111 | "gemini", |
| 112 | "openai_agents", |
| 113 | "google_adk", |
| 114 | "llamaindex", |
| 115 | ) |
| 116 | |
| 117 | |
| 118 | @nox.session |
| 119 | def tst(session: Session): |
| 120 | """Run the Python unit test suite.""" |
| 121 | session.install(".", "--group", "dev") |
| 122 | session.install("./providers/crewai") |
| 123 | session.install("./providers/langchain") |
| 124 | session.install("./providers/langgraph") |
| 125 | session.install("./providers/gemini") |
| 126 | session.install("./providers/google") |
| 127 | session.install("./providers/openai_agents") |
| 128 | session.install("./providers/claude_agent_sdk") |
| 129 | session.install("./providers/anthropic") |
| 130 | session.install("./providers/google_adk") |
| 131 | session.install("./providers/llamaindex") |
| 132 | # The free-form argument matrix fails, rather than skips, for these. |
| 133 | env = {"COMPOSIO_EXPECTED_PROVIDERS": " ".join(TST_MATRIX_PROVIDERS)} |
| 134 | if session.posargs: |
| 135 | session.run("pytest", *session.posargs, "-v", "--tb=short", env=env) |
| 136 | return |
| 137 | # Separate runs: the provider packages' `test_provider.py` files share a |
| 138 | # basename with tests/, which pytest cannot collect in a single session. |
| 139 | for test_path in ( |
| 140 | "tests/", |
| 141 | "providers/openai_agents/tests", |
| 142 | "providers/claude_agent_sdk/tests", |
| 143 | "providers/anthropic/tests", |
| 144 | ): |
| 145 | session.run("pytest", test_path, "-v", "--tb=short", env=env) |
| 146 | |
| 147 | |
| 148 | @nox.session |
| 149 | def tst_autogen(session: Session): |
| 150 | """Run Autogen tests in its protobuf-compatible environment.""" |
| 151 | session.install(".", "--group", "dev") |
| 152 | session.install("./providers/autogen") |
| 153 | session.run( |
| 154 | "pytest", |
| 155 | "tests/test_provider.py::TestAgenticSkipDefaultsParity::test_autogen_signature_honors_skip_defaults", |
| 156 | "tests/test_provider.py::TestAgenticSkipDefaultsParity::test_autogen_signature_preserves_default", |
| 157 | "tests/test_provider_argument_serialization.py", |
| 158 | "-v", |
| 159 | "--tb=short", |
| 160 | env={"COMPOSIO_EXPECTED_PROVIDERS": "autogen"}, |
| 161 | ) |
| 162 | |
| 163 | |
| 164 | @nox.session |
| 165 | def tst_typesafe(session: Session): |
| 166 | """Run the TypeSafe provider tests, which `tst` skips without the provider.""" |
| 167 | session.install(".", "--group", "dev") |
| 168 | session.install("./providers/typesafe", "typesafe-sdk==0.6.0") |
| 169 | session.run( |
| 170 | "python", |
| 171 | "-c", |
| 172 | "import composio, composio_typesafe; " |
| 173 | "print(composio.__file__); print(composio_typesafe.__file__)", |
| 174 | ) |
| 175 | session.run("pytest", "tests/test_typesafe_provider.py", "-v", "--tb=short") |
| 176 | |
| 177 | |
| 178 | @nox.session |
| 179 | def snt(session: Session): |
| 180 | """Run fast sanity tests for imports and SDK initialization.""" |
| 181 | session.install(".", "--group", "dev") |
| 182 | test_paths = session.posargs or ["tests/test_imports.py", "tests/test_sdk.py"] |
| 183 | session.run("pytest", *test_paths, "-v", "--tb=short") |
| 184 | |
| 185 | |
| 186 | @nox.session |
| 187 | def type_inference(session: Session): |
| 188 | """Type check provider return type inference tests. |
| 189 | |
| 190 | This session verifies that mypy correctly infers provider-specific return |
| 191 | types from `Composio.tools.get()` when using @overload signatures. |
| 192 | |
| 193 | Unlike the `chk` session, this installs all provider packages so mypy can |
| 194 | resolve the provider types and verify the type inference works correctly. |
| 195 | """ |
| 196 | # Install core SDK, shared dev tooling, and mypy |
| 197 | session.install(".", "--group", "dev", mypy, *type_stubs) |
| 198 | |
| 199 | # Install all provider packages for type resolution |
| 200 | session.install( |
| 201 | "./providers/anthropic", |
| 202 | "./providers/autogen", |
| 203 | "./providers/claude_agent_sdk", |
| 204 | "./providers/crewai", |
| 205 | "./providers/gemini", |
| 206 | "./providers/google", |
| 207 | "./providers/google_adk", |
| 208 | "./providers/langchain", |
| 209 | "./providers/langgraph", |
| 210 | "./providers/llamaindex", |
| 211 | "./providers/openai", |
| 212 | "./providers/openai_agents", |
| 213 | "./providers/typesafe", |
| 214 | ) |
| 215 | |
| 216 | # Run mypy on type inference test files |
| 217 | # Note: explicitly listed files are checked even if they match the exclude pattern in `mypy.ini` |
| 218 | session.run( |
| 219 | "mypy", |
| 220 | "--config-file", |
| 221 | "config/mypy.ini", |
| 222 | "tests/test_type_inference.py", |
| 223 | "tests/test_type_inference_anthropic.py", |
| 224 | "tests/test_type_inference_autogen.py", |
| 225 | "tests/test_type_inference_claude_agent_sdk.py", |
| 226 | "tests/test_type_inference_crewai.py", |
| 227 | "tests/test_type_inference_gemini.py", |
| 228 | "tests/test_type_inference_google.py", |
| 229 | "tests/test_type_inference_google_adk.py", |
| 230 | "tests/test_type_inference_langchain.py", |
| 231 | "tests/test_type_inference_langgraph.py", |
| 232 | "tests/test_type_inference_llamaindex.py", |
| 233 | "tests/test_type_inference_openai_agents.py", |
| 234 | "tests/test_type_inference_typesafe.py", |
| 235 | ) |
| 236 | |
| 237 | |
| 238 | # Modules scanned for dead code (source only, no tests/examples/scripts) |
| 239 | modules_for_vulture = [ |
| 240 | "composio/", |
| 241 | "providers/", |
| 242 | ] |
| 243 | |
| 244 | |
| 245 | @nox.session(name="dead_code") |
| 246 | def dead_code(session: Session): |
| 247 | """Report likely-dead code (unused functions, classes, variables). |
| 248 | |
| 249 | Report-only: vulture exits 1 when it finds candidates, but we do not fail |
| 250 | the session on that so it never blocks CI on false positives. Vet the |
| 251 | output by hand; suppress confirmed false positives by adding the symbol to |
| 252 | ``config/vulture_allowlist.py``. Ruff already covers unused imports (F401) |
| 253 | and unused locals (F841) in the `chk` session; vulture adds cross-module |
| 254 | unused functions/classes that ruff cannot see. |
| 255 | """ |
| 256 | session.install("vulture>=2.14") |
| 257 | session.run( |
| 258 | "vulture", |
| 259 | *modules_for_vulture, |
| 260 | "config/vulture_allowlist.py", |
| 261 | "--min-confidence", |
| 262 | "80", |
| 263 | "--exclude", |
| 264 | "*/build/*,*/dist/*,*/.venv/*,*/.nox/*,*/__pycache__/*", |
| 265 | # vulture exit codes: 0 = clean, 3 = candidates found. Report-only, so |
| 266 | # neither should fail the session. (1/2 are real usage/parse errors.) |
| 267 | success_codes=[0, 3], |
| 268 | ) |