Skip to content

Commit 0645fb0

Browse files
fix(ci): pyright/mypy extraPaths for adk/src, pytest --import-mode=importlib
Two CI breakages I didn't catch locally: 1. **pyright didn't know about adk/src/** so all `from agentex.lib.*` imports failed `reportMissingImports`. Pyright doesn't auto-discover editable installs the way Python's runtime does. Fix: - Add `extraPaths = ["src", "adk/src"]` at root of [tool.pyright] and per execution-environment. This tells pyright to resolve imports against both source trees. - Update the strict-typecheck execution environment root from the deleted `src/agentex/lib` to `adk/src/agentex/lib`. - Add a new tests/-equivalent execution environment for `adk/tests`. - Same fix for mypy: add `mypy_path = "src:adk/src"`, exclude `adk/tests/.*` to match the tests/.* exclusion. 2. **pytest collected tests/ and adk/tests/ as both being top-level package `tests`** (both have __init__.py), so it hit "duplicate package name" errors: ERROR collecting adk/tests/lib/adk - ModuleNotFoundError: No module named 'tests.lib' Fix: `--import-mode=importlib` in addopts. This is the modern recommended pytest mode and tolerates same-name test packages. Verified locally with `pytest --collect-only tests adk/tests --import-mode=importlib`: 2204 tests collected cleanly, no errors. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ee1d1fe commit 0645fb0

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ replacement = '[\1](https://github.com/scaleapi/scale-agentex-python/tree/main/\
160160
# tests resolve `agentex.lib.*` via the sibling agentex-sdk package installed
161161
# editably by scripts/bootstrap.
162162
testpaths = ["tests", "adk/tests"]
163-
addopts = "--tb=short -n auto"
163+
# importlib mode avoids the "duplicate package name" collision that classic
164+
# import mode hits when both tests/ and adk/tests/ have __init__.py making
165+
# them both look like a top-level `tests` package.
166+
addopts = "--tb=short -n auto --import-mode=importlib"
164167
xfail_strict = true
165168
asyncio_mode = "auto"
166169
asyncio_default_fixture_loop_scope = "session"
@@ -174,6 +177,12 @@ filterwarnings = [
174177
typeCheckingMode = "basic"
175178
pythonVersion = "3.12"
176179

180+
# Both src/ (slim client) and adk/src/ (ADK overlay) contribute to the
181+
# agentex.* namespace. Pyright needs both as roots so cross-package imports
182+
# (e.g. agentex.lib.* code referencing agentex.types.*) resolve.
183+
include = ["src", "adk/src", "tests", "adk/tests", "examples", "scripts", "bin"]
184+
extraPaths = ["src", "adk/src"]
185+
177186
exclude = [
178187
"_dev",
179188
".venv",
@@ -201,24 +210,34 @@ reportUnknownVariableType = false
201210

202211
# Enable strict type checking only for hand-written code
203212
[[tool.pyright.executionEnvironments]]
204-
root = "src/agentex/lib"
213+
root = "adk/src/agentex/lib"
205214
typeCheckingMode = "strict"
215+
extraPaths = ["src", "adk/src"]
206216
# But allow some flexibility in OpenAI module for complex type boundaries
207217
reportArgumentType = false
208218

209219
[[tool.pyright.executionEnvironments]]
210220
root = "examples"
211221
typeCheckingMode = "strict"
222+
extraPaths = ["src", "adk/src"]
212223
# Allow type ignores in tutorials for readability
213224
reportUnnecessaryTypeIgnoreComment = false
214225

215226
[[tool.pyright.executionEnvironments]]
216227
root = "tests"
217228
typeCheckingMode = "basic"
229+
extraPaths = ["src", "adk/src"]
218230
# Be loose on typing in tests unless testing types specifically
219231
reportOptionalMemberAccess = false
220232
reportArgumentType = false
221233

234+
[[tool.pyright.executionEnvironments]]
235+
root = "adk/tests"
236+
typeCheckingMode = "basic"
237+
extraPaths = ["src", "adk/src"]
238+
reportOptionalMemberAccess = false
239+
reportArgumentType = false
240+
222241
[tool.mypy]
223242
pretty = true
224243
show_error_codes = true
@@ -229,7 +248,8 @@ show_error_codes = true
229248
#
230249
# We also exclude our `tests` as mypy doesn't always infer
231250
# types correctly and Pyright will still catch any type errors.
232-
exclude = ['src/agentex/_files.py', '_dev/.*.py', 'tests/.*', 'examples/tutorials/.*']
251+
exclude = ['src/agentex/_files.py', '_dev/.*.py', 'tests/.*', 'adk/tests/.*', 'examples/tutorials/.*']
252+
mypy_path = "src:adk/src"
233253

234254
strict_equality = true
235255
implicit_reexport = true

0 commit comments

Comments
 (0)