Rename TModel TypeVar to _TModel to fix broken doc links#240
Rename TModel TypeVar to _TModel to fix broken doc links#240
Conversation
Agent-Logs-Url: https://github.com/microsoft/Agent365-python/sessions/dbf4ac27-2d8a-4a26-bc1d-bdd20a8e264c Co-authored-by: JimDaly <6353736+JimDaly@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR addresses broken DocFx cross-reference links by making a module-level TypeVar private in AgentNotificationActivity, preventing it from being treated as a public documented symbol.
Changes:
- Renamed the module-scope
TypeVarfromTModelto_TModel. - Updated
AgentNotificationActivity.as_modeltype annotations to use_TModel.
| # Generic escape hatch | ||
| def as_model(self, model: Type[TModel]) -> Optional[TModel]: | ||
| def as_model(self, model: Type[_TModel]) -> Optional[_TModel]: |
There was a problem hiding this comment.
as_model calls model.model_validate(...), but the annotation model: Type[_TModel] doesn’t guarantee that the passed type has a model_validate classmethod. Consider bounding _TModel to pydantic.BaseModel (or using type[BaseModel] directly) so static type checkers can validate correct usage.
|
After consulting with the learn platform team, closing this since it may not fix the problem. |
DocFx treats module-level
TypeVarinstances as public documented types and generates<xref:...TModel>cross-reference links that resolve to nothing, producing broken links in theAgentNotificationActivity.as_modeldocumentation.Change
Rename the module-scope
TypeVarfromTModelto_TModelinagent_notification_activity.py. The underscore prefix marks it as private; doc generators skip cross-reference link generation for private symbols and render the type as plain text instead.This also aligns with standard Python convention:
TypeVars not part of a public generic API should always be underscore-prefixed.