You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python: Split type checkers by target (pyright source, 5 checkers on tests/samples)
Rework the typing setup along the lines of the 'too many type checkers'
approach:
- Pyright (strict) is now the sole source-code type checker; mypy is
removed from source and its [tool.mypy] block becomes a relaxed profile
used only for tests/samples.
- Tests are checked by all five checkers (pyright relaxed, mypy, pyrefly,
ty, zuban); samples by pyright, pyrefly, and ty. All run in a relaxed/
basic profile so authors aren't forced into over-annotation.
- Add pyrightconfig.tests.json and bump sample pyright configs to basic.
- Unify test/sample typing onto the same parallel fan-out used by source
pyright via run_command_items in task_runner.py.
- Make version-conditional imports symmetric: keep or drop the
'# type: ignore' on both branches so results match across interpreter
versions (local vs CI).
- Update SKILL.md, DEV_SETUP.md, and CODING_STANDARD.md for the five
gating checkers and pyright on source+tests+samples.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: python/CODING_STANDARD.md
+10-3Lines changed: 10 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,11 +92,18 @@ Use typing as a helper first and suppressions as a last resort:
92
92
-**Prefer explicit typing before suppression**: Start with clearer type annotations, helper types, overloads,
93
93
protocols, or refactoring dynamic code into typed helpers. Prioritize performance over completeness of typing, but make a good-faith effort to reduce uncertainty with typing before ignoring. Prefer to use a cast over a typeguard function since that does add overhead.
94
94
-**Avoid redundant casts**: Do not add `cast(...)` if the type already matches; casts should be reserved for
95
-
unavoidable narrowing where the runtime contract is known, we will use mypy's check on redundant casts to enforce this.
95
+
unavoidable narrowing where the runtime contract is known.
96
96
-**Avoid multiple assignments**: Avoid assigning multiple variables just to get typing to pass, that has performance impact while typing should not have that.
97
-
-**Line-level pyright ignores only**: If suppression is still required, use a line-level rule-specific ignore
97
+
-**Source vs tests/samples**: Source code (`agent_framework*`) is checked **by pyright in strict mode** — use
98
+
`# pyright: ignore[...]` there, never `# type: ignore` (strict pyright flags unnecessary ignores as errors). Tests
99
+
and samples are checked by pyright (relaxed `basic`), mypy, pyrefly, ty (and zuban on tests) in a relaxed/basic
100
+
profile; prefer real fixes (`isinstance`, `cast`, annotations, asserts for Optional access) over per-line ignores,
101
+
and keep test/sample bodies readable rather than over-annotated. When a relaxed-pyright suppression is genuinely
102
+
needed in tests/samples, use `# pyright: ignore[rule]`; the relaxed test/sample configs do not flag unnecessary
103
+
ignores, so combine with a mypy/zuban `# type: ignore[code]` on the same line only where both are required.
104
+
-**Line-level pyright ignores only**: If suppression is still required in source, use a line-level rule-specific ignore
98
105
(`# pyright: ignore[reportGeneralTypeIssues]`), file-level is allowed if there is a compelling reason for it, that should be documented right beneath the ignore.
99
-
Never change the global suppression flags for mypy and pyright unless the dev team okays it.
106
+
Never change the global suppression flags unless the dev team okays it.
100
107
-**Private usage boundary**: Accessing private members across `agent_framework*` packages can be acceptable for this
101
108
codebase, but private member usage for non-Agent Framework dependencies should remain flagged.
0 commit comments