Fix docstring type annotations for Microsoft Learn compatibility#153
Fix docstring type annotations for Microsoft Learn compatibility#153
Conversation
Replace Sphinx-style ':class:\list\ of :class:\str\' patterns with Python bracket notation (list[str], dict[str, Any], etc.) in :type: and :rtype: directives. The Learn doc pipeline treats each word between :class: references as a separate cross-reference (<xref:word>), causing connector words like 'of', 'mapping', and 'to' to produce broken <xref:of>, <xref:mapping>, <xref:to> links that cannot be resolved. Files fixed: - client.py (14 occurrences) - operations/records.py (14 occurrences) - operations/tables.py (7 occurrences) - operations/dataframe.py (3 occurrences) - operations/query.py (1 occurrence) - models/table_info.py (3 occurrences) This reverts to the bracket notation style that was originally used before the Sphinx docstring conversion in commit f0e8987.
Add 'Docstring Type Annotations (Microsoft Learn Compatibility)' section to both SKILL.md copies with rules, correct/wrong examples to prevent the ':class:\X\ of :class:\Y\' anti-pattern from being reintroduced.
Document Learn-compatible docstring rules for external contributors to prevent reintroduction of broken <xref:of> cross-references.
There was a problem hiding this comment.
Pull request overview
Updates docstring :type:/:rtype: annotations to avoid Microsoft Learn’s broken <xref:of>, <xref:mapping>, and <xref:to> cross-references, while keeping the SDK’s public API documentation readable and consistent.
Changes:
- Replaced Sphinx-style generic type phrases (e.g., ``:class:
listof :class:`str``` ) with bracket notation (e.g., `list[str]`) across the SDK’s public operation/client docstrings. - Updated the developer SKILL guides (both copies) with explicit Microsoft Learn–compatible rules and examples for docstring type directives.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/PowerPlatform/Dataverse/operations/tables.py | Updates :type:/:rtype: generics to bracket notation for Learn compatibility. |
| src/PowerPlatform/Dataverse/operations/records.py | Updates :type:/:rtype: generics (including nested/iterable types) to bracket notation. |
| src/PowerPlatform/Dataverse/operations/query.py | Updates :rtype: list generic annotation to bracket notation. |
| src/PowerPlatform/Dataverse/operations/dataframe.py | Updates list-based parameter :type: annotations to bracket notation. |
| src/PowerPlatform/Dataverse/models/table_info.py | Updates :type: list generics in model docstrings to bracket notation. |
| src/PowerPlatform/Dataverse/client.py | Updates CRUD/metadata helper docstring :type:/:rtype: generics to bracket notation. |
| src/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-dev/SKILL.md | Adds Learn-compatible docstring type annotation rules and examples. |
| .claude/skills/dataverse-sdk-dev/SKILL.md | Same Learn-compatible guidance added; kept in sync with the packaged skill copy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
src/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-dev/SKILL.md
Outdated
Show resolved
Hide resolved
|
@microsoft-github-policy-service agree company="Microsoft" |
Address PR review: use typing.Any consistently in rules bullet to match the examples and actual docstrings.
There was a problem hiding this comment.
Pull request overview
Updates docstring :type:/:rtype: annotations to avoid broken Microsoft Learn cross-references caused by Sphinx-style :class:… of …/mapping … to … patterns.
Changes:
- Replaced generic/compound Sphinx
:class:type expressions in docstrings with Python bracket notation (e.g.,list[str],dict or list[dict],collections.abc.Iterable[list[dict]]). - Updated multiple operation/client/model modules’ docstrings to align with Microsoft Learn parsing behavior.
- Added contributor guidance documenting the required docstring type-annotation patterns.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/PowerPlatform/Dataverse/operations/tables.py |
Docstring :type:/:rtype: updates to bracket generics. |
src/PowerPlatform/Dataverse/operations/records.py |
Docstring type annotations rewritten to avoid Learn <xref:of>-style breakage. |
src/PowerPlatform/Dataverse/operations/query.py |
Docstring :rtype: updated to bracket generic form. |
src/PowerPlatform/Dataverse/operations/dataframe.py |
Docstring parameter type annotations updated to list[str] forms. |
src/PowerPlatform/Dataverse/models/table_info.py |
Model docstring type annotations updated to bracket generics. |
src/PowerPlatform/Dataverse/client.py |
Client API docstring type annotations updated; avoids mapping … to … pattern. |
src/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-dev/SKILL.md |
Added Learn-compatible docstring type-annotation guidance. |
.claude/skills/dataverse-sdk-dev/SKILL.md |
Same guidance added to the repo-local skill copy. |
CONTRIBUTING.md |
Added contributor-facing rules for Learn-compatible :type:/:rtype: usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Move inline Sphinx examples with nested backticks into fenced code blocks and use double-backtick code spans so the literal :class: text renders correctly in GitHub Markdown.
Release changelog for v0.1.0b8. ## Changes included in this release ### Added - Batch API: `client.batch` namespace for deferred-execution batch operations (#129) - Batch DataFrame integration: `client.batch.dataframe` namespace (#129) - `client.records.upsert()` and `client.batch.records.upsert()` with alternate-key support (#129) - QueryBuilder: `client.query.builder()` with fluent API and composable filter expressions (#118) - Memo/multiline column type support in `client.tables.create()` and `client.tables.add_columns()` (#155) ### Changed - Picklist label resolution now uses a single bulk API call per table with 1-hour TTL cache (#154) ### Fixed - `client.query.sql()` now paginates and returns all rows instead of truncating at 5,000 (#157) - Alternate key fields no longer merged into `UpsertMultiple` request body (#129) - Docstring type annotations corrected for Microsoft Learn compatibility (#153) --------- Co-authored-by: Abel Milash <abelmilash@microsoft.com>
Release changelog for v0.1.0b8. ## Changes included in this release ### Added - Batch API: `client.batch` namespace for deferred-execution batch operations (#129) - Batch DataFrame integration: `client.batch.dataframe` namespace (#129) - `client.records.upsert()` and `client.batch.records.upsert()` with alternate-key support (#129) - QueryBuilder: `client.query.builder()` with fluent API and composable filter expressions (#118) - Memo/multiline column type support in `client.tables.create()` and `client.tables.add_columns()` (#155) ### Changed - Picklist label resolution now uses a single bulk API call per table with 1-hour TTL cache (#154) ### Fixed - `client.query.sql()` now paginates and returns all rows instead of truncating at 5,000 (#157) - Alternate key fields no longer merged into `UpsertMultiple` request body (#129) - Docstring type annotations corrected for Microsoft Learn compatibility (#153) --------- Co-authored-by: Abel Milash <abelmilash@microsoft.com>
Summary
Fix broken cross-references (
<xref:of>,<xref:mapping>,<xref:to>) in the Microsoft Learn API reference docs caused by Sphinx-style:type:and:rtype:directives.Problem
The Learn doc pipeline processes
:type:and:rtype:Sphinx directives differently from standard Sphinx. Every word between:class:back-tick references is treated as a separate cross-reference. For example:Becomes:
There is no type
ofin the Learn cross-reference database, so it renders as a broken link on the published page.Root Cause
This was introduced in commit f0e8987 ("sphinx doc string", 2025-11-17) which converted the original bracket-notation docstrings (
list[str],dict or list[dict]) to Sphinx-style:class:syntax. Later commits that added new APIs (operation namespaces, dataframe, etc.) perpetuated the same broken pattern.Fix
Replaced all 42 occurrences across 6 source files with Python bracket notation that the Learn pipeline handles correctly:
:class:\list` of :class:`str``list[str]:class:\dict` or :class:`list` of :class:`dict``dict or list[dict]:class:\collections.abc.Iterable` of :class:`list` of :class:`dict``collections.abc.Iterable[list[dict]]:class:\dict` mapping :class:`str` to :class:`typing.Any``dict[str, typing.Any]Files changed
Docstring fixes:
src/PowerPlatform/Dataverse/client.py(14 occurrences)src/PowerPlatform/Dataverse/operations/records.py(14 occurrences)src/PowerPlatform/Dataverse/operations/tables.py(7 occurrences)src/PowerPlatform/Dataverse/operations/dataframe.py(3 occurrences)src/PowerPlatform/Dataverse/operations/query.py(1 occurrence)src/PowerPlatform/Dataverse/models/table_info.py(3 occurrences)Prevention guidelines:
.claude/skills/dataverse-sdk-dev/SKILL.md-- added "Docstring Type Annotations (Microsoft Learn Compatibility)" sectionsrc/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-dev/SKILL.md-- same section (kept both copies in sync)Testing