Research: stdlib stub docstring enrichment from typeshed and CPython sources #699
+1,140
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Research options to enrich MicroPython stdlib stubs with docstrings from CPython/typeshed without overwriting MicroPython-specific documentation.
Findings
BasedPyright/Pyright Integration
node_modules/basedpyright/dist/typeshed/stdlib/CPython Docstring Extraction
inspectmodule provides rich documentationjsonandsysmodules (41 functions extracted)Existing Infrastructure
merge_docstub.pycodemod handles type-rich stub mergingtypeshed_incomplete_pyidemonstrates CPython-like stub integrationRecommendation: Hybrid Approach
Extract type information from typeshed + docstrings from CPython runtime, merge with strict preservation:
Critical Rules:
Deliverables
Documentation (33KB)
docs/README_stdlib_docstrings.md- Indexdocs/research_summary_stdlib_docstrings.md- Executive summarydocs/research_stdlib_docstrings.md- Technical deep-dive (13KB)docs/implementation_guide_stdlib_docstrings.md- Implementation roadmapProof-of-Concept Scripts (tested ✅)
/tmp/extract_typeshed_poc.py- Extracts from basedpyright npm package/tmp/extract_cpython_docstrings.py- Extracts CPython docstrings via runtimeImplementation Phases
merge_docstub.py, add preservation logic (2-3 weeks)Decision Points
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.