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: Fix Python pyright package scoping and typing remediation (#4426)
* Fix Python pyright package scoping and typing remediation
Implements issue #4407 by removing the root pyright include, adding package-level pyright includes, and resolving pyright/mypy typing issues across Python packages. Also cleans unnecessary casts and applies line-level, rule-specific ignores where external libraries are too dynamic.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Reduce pyright cost in handoff cloning
Simplify cloned_options construction in HandoffAgentExecutor to avoid expensive TypedDict narrowing/inference in _handoff.py, which was causing pyright to spend a long time in orchestrations.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix types
* Fix lint and type-check regressions
Resolve current Python package check failures across lint, pyright, and mypy after recent code changes, including purview/declarative pyright issues and multiple ruff simplification findings.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fixed hooks
* Stabilize package tests and test tasks
Resolve cross-package non-integration test failures, simplify streaming type flow, harden locale/culture handling, and standardize package test poe tasks to exclude integration tests where applicable.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* lots of small fixes
* Fix current Python test regressions
Address current failing unit tests in azure-ai, bedrock, and azure-cosmos while keeping Bedrock parsing logic inline (no new static helper methods).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* small fixes
* small fixes
* removed pydantic from json
* final updates
* fix core
* fix tests
* fix obser
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: python/CODING_STANDARD.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,12 @@ Public modules must include a module-level docstring, including `__init__.py` fi
27
27
28
28
## Type Annotations
29
29
30
+
We use typing as a helper, it is not a goal in and of itself, so be pragmatic about where and when to strictly type, versus when to use a targetted cast or ignore.
31
+
In general, the public interfaces of our classes, are important to get right, internally it is okay to have loosely typed code, as long as tests cover the code itself.
32
+
This includes making a conscious choice when to program defensively, you can always do `getattr(item, 'attribute')` but that might end up causing you issues down the road
33
+
because the type of `item` in this case, should have that attribute and if it doesn't it points to a larger issue, so if the type is expected to have that attribute, you should
34
+
use `item.attribute` to ensure it fails at that point, rather then somewhere downstream where a value is expected but none was found.
35
+
30
36
### Future Annotations
31
37
32
38
> **Note:** This convention is being adopted. See [#3578](https://github.com/microsoft/agent-framework/issues/3578) for progress.
Use typing as a helper first and suppressions as a last resort:
91
+
92
+
-**Prefer explicit typing before suppression**: Start with clearer type annotations, helper types, overloads,
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
+
-**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.
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
98
+
(`# 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.
100
+
-**Private usage boundary**: Accessing private members across `agent_framework*` packages can be acceptable for this
101
+
codebase, but private member usage for non-Agent Framework dependencies should remain flagged.
0 commit comments