Repository navigation
Match remaining native docs and signatures to CPython 3.14 - #8877
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: RustPython/RustPython/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (44)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe changes expand documentation discovery and runtime documentation assignment. They also update several Python-visible API declarations, add a ctypes method, and adjust source comments and module documentation. ChangesDocumentation discovery and exposure
Python-visible API and metadata updates
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No identified compatibility issue remains that should prevent merging after normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
93ca4a4 to
2c3ca84
Compare
Merging this PR will improve performance by 10.54%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | rustpython[richards.py] |
1.9 ms | 1.7 ms | +10.54% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing youknowone:whats-left-signatures (c5540e9) with main (b499e70)
Footnotes
-
4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
d58ff62 to
ba1977b
Compare
- Stop ignoring `__dir__`; skip `__base__`, `__bases__` and `__module__` instead. - Recurse into native classes whose metaclass is not `type`, and also key a class stored under another attribute name by its own `__name__`. - Collect native objects exposed by pure-Python modules, such as the codec error handlers, under their own `__module__` and `__name__`. - Key types found through `object.__subclasses__()` by their own module as well as `builtins`. - Record getset/member descriptors named like class metadata (`coroutine.__name__`), and native types a module exposes only through an instance (`sys.flags`). - Treat a class as native only when it owns its C descriptors, so an enum holding a copied `str.__format__` is skipped. - Keep docstrings unstripped, and import every module in sorted order before walking them. - Apply the resulting key delta, measured on macOS with CPython 3.14.7, to data.inc.rs. Assisted-by: Claude:claude-opus-5-5 Assisted-by: Grok:grok-4.7
Use `//` instead of `///` on Python-exposed items so their comments are not published as `__doc__`. Assisted-by: Claude:claude-opus-5-5 Assisted-by: Grok:grok-4.7
- Rename the weakref type to `weakref.ReferenceType` and define `__class_getitem__` on `_ctypes.Array` instead of its metaclass. - Give each name of a multi-name `#[pymodule(sub)]` function (`posix.remove`/`unlink`) its database doc. - Fill methods from `with(...)` traits (dict view `__reversed__`, `isdisjoint`) with the implementing class's database doc. - Resolve database docs for `#[pymodule]` classes at macro time, and for the codec error handlers and `_lzma.LZMAError` in const context. - Add `Context::new_exception_type_with_doc`. - Match `posix_spawn` parameter names and defaults, make `dict_keys` and `dict_items` unhashable, add `_CData.__ctypes_from_outparam__`, and omit the Windows-only lines of `sys.__doc__` on other platforms. Assisted-by: Claude:claude-opus-5-5 Assisted-by: Grok:grok-4.7
`new_readonly_tuple_member` takes the field doc, looked up in the class's attribute doc table through the new `class_attr_item_doc`. Assisted-by: Claude:claude-opus-5-5
posix and nt share one doc entry. A sub module sets name to the Python module it is merged into, and doc lookup uses that name. Assisted-by: Claude:claude-opus-5-5 Assisted-by: Grok:grok-4.7
The pymethod derive sets doc_body_pending when a method has no Rust doc body and expansion did not resolve a database span. concat_with_attr_docs copies that span from the class table and clears the flag. Other constructors leave the flag false. Assisted-by: Claude:claude-opus-5-5 Assisted-by: Grok:grok-4.7
PosixSpawnArgs.args is renamed to argv, and nt's follow_symlinks field drops a name override equal to the field name. Assisted-by: Claude:claude-opus-5-5
19f158f to
c5540e9
Compare
Follow-up to #8836. Fixes the remaining native
__doc__/signature mismatches thatscripts/whats_left.py --doc --signaturereports under CPython 3.14.7, except those from modules RustPython implements in pure Python.Doc DB generator (
crates/doc/generate.py)__dir__was inIGNORED_ATTRS, soobject.__dir__,type.__dir__etc. were never recorded. It is no longer ignored;__base__,__bases__and__module__are skipped instead because following them only re-records other objects under a bogus path (this removes 22builtins.type.__base__*keys).type, and classes stored under another attribute name keyed by their own__name__(_json.make_scanneris the class_json.Scanner)__module__/__name__(ssl.SSLError), or by the exposing module when__module__is None (thecodecs.*_errorshandlers)object.__subclasses__()keyed by their own module as well asbuiltins(_ctypes._CData)getmembers()hides behind the class's own value (coroutine.__name__)sys.flags,sys.float_info, …)__objclass__ is cls). Before, an enum holding a copiedstr.__format__looked native..strip()removed leading indentation thatinspect.cleandocdepends on (_sre.template).PYTHONHASHSEED.data.inc.rsgets the key delta between the old and new generator, both run on macOS with CPython 3.14.7: 5,042 added, 22 removed, 1,773 values changed (mostly unstripped whitespace). Linux/Windows-only keys are picked up by the nextupdate-doc-dbrun.///on Python itemsRust
///comments on#[py*]items were published as__doc__(e.g.weakref.refwas "PyWeakReference: …"). They are now//. Most of this is split out as #8893; this PR keeps the struct sequence__replace__andcoroutine.__name__/__qualname__ones, which need the database entries added here.Names, lookup and signatures
weakref.ReferenceType;_ctypes.Array.__class_getitem__is defined onArray, not its metaclass.#[pymodule(sub)]bodies declare the Python module they are merged into withname = "...", and doc lookup uses it; withoutnamethe database is not consulted. This replaces a guess that searched every module for a unique function name.posixandntfall back to each other inrustpython_doc::get_qualified, since they are one module under a platform-dependent name. Each name of a multi-name function gets its own doc (posix.remove/posix.unlink).posix.DirEntry/ScandirIterhave__module__posix(was_os), andodict_keys/odict_values/odict_items/odict_iteratorhavebuiltins(wasordered_dict).with(...)traits get the implementing class's doc (dict_items.__reversed__,dict_items.isdisjoint,dict_values.__reversed__). The trait impl cannot name the class, so the derive marks such a methoddoc_body_pendingon itsPyMethodDef, and the class fills the span from its attribute doc table when it concatenates the method arrays.#[pymodule]classes without their own doc get the database doc, resolved at macro time. The codec error handlers and_lzma.LZMAErrorresolve theirs in const context through the newItemDoc::db.Context::new_exception_type_with_docis added for the latter. No database lookup happens at runtime, so the key table stays out of the binary.posix_spawn/posix_spawnp: parameterargv(the field is renamed rather than overridden withname =) and defaultsfile_actions=(),setpgroup=None,setsigmask=(),setsigdef=(),scheduler=Nonein CPython's order.dict_keysanddict_itemsare unhashable;_CData.__ctypes_from_outparam__is added;sys.__doc__omits the[Windows only]lines on other platforms.Struct sequence fields
Since #8857 made struct sequence fields member descriptors, their
__doc__has been None (os.stat_result.st_mode,time.struct_time.tm_year,_thread._ExceptHookArgs.exc_type).new_readonly_tuple_membernow takes the field's database doc.Results (macOS arm64, CPython 3.14.7 as reference)
__doc__mismatches outside decimal/datetime/zoneinfodict_items.__hash__)A
__doc__dump over every builtin module's classes, functions and descriptors (5,168 entries) matches CPython in 201 more places than 1a259e4 and in none fewer.The remaining 267 doc mismatches are all
decimal.*,datetime.*andzoneinfo.*: RustPython uses_pydecimal,_pydatetimeand_zoneinfo's pure-Python fallbacks there.¹
functools._make_key,logging.shutdown,platform.architectureand_py_warnings._deprecatedrender set ordering, paths orsys.version_infoin their defaults.Release binary: 38,088,784 bytes, against 38,048,448 for a 1a259e4 build (+40 KB, mostly the new struct sequence field and attribute doc tables).
Verified with workspace + capi clippy (
-D warnings),cargo check --no-default-featureswithoutdoc, andcargo test --workspace. These unittests pass: test_inspect, test_pydoc, test_weakref, test_ctypes, test_json, test_codecs, test_ssl, test_posix, test_os, test_dict, test_sys, test_lzma, test_builtin, test_descr, test_types, test_zlib, test_csv, test_pickle, test_coroutines, test_time, test_structseq, test_thread and test_threading.extra_testsshows no new failures.🤖 Generated with Claude Code