GeezerVison is showing github.com — Add macro for type check functions in c-api by bschoenmaeckers · Pull Request #7871 · RustPython/RustPython
Conversation
bschoenmaeckers
commented
May 13, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
- New Features
- Added exported C API functions providing runtime type checks (exact-type and subtype checks) for extension modules.
- Introduced a C-accessible subtype query to inspect type relationships between runtime types.
- Expanded interoperability surface for extensions performing type inspections and comparisons.

Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
May 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: c7fad624-873f-4cf8-8222-9dd4250cc2d6
📥 Commits
Reviewing files that changed from the base of the PR and between 69b9f04 and cc1455b.
📒 Files selected for processing (1)
crates/capi/src/object.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/capi/src/object.rs
📝 Walkthrough
Walkthrough
Adds a macro-generated pair of C-exported functions PyType_Check (subtype) and PyType_CheckExact (exact match), plus PyType_IsSubtype(a, b); all run their checks inside with_vm and return results as c_int.
Changes
Type-checking C API exports
| Layer / File(s) |
Summary |
Type-checking and type relationship functions crates/capi/src/object.rs |
define_py_check! macro defines PyType_Check and PyType_CheckExact to run subtype/exact checks against vm.ctx.types.type_type inside with_vm; PyType_IsSubtype dereferences *const PyTypeObject inputs, calls a.is_subtype(b) inside with_vm, and returns a c_int result. |
Sequence Diagram(s)
sequenceDiagram
participant Caller
participant with_vm
participant vm_ctx_types_type_type
participant PyTypeObject
Caller->>with_vm: call PyType_Check(obj) / PyType_CheckExact(obj)
with_vm->>vm_ctx_types_type_type: compare obj.type against ctx.types.type_type
Caller->>with_vm: call PyType_IsSubtype(a, b)
with_vm->>PyTypeObject: call a.is_subtype(b)
Loading
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested reviewers
Poem
🐰 I hopped through vm's cozy den,
Peeked at types and then again,
Exact or subtype — a tiny quest,
Returned a number, passed the test,
Hooray, C calls now know the rest!
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title accurately describes the main change: adding a macro for type check functions in the C API, which aligns with the introduction of define_py_check! macro and the three exported type-checking functions. |
| Docstring Coverage |
✅ Passed |
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced May 17, 2026
This was referenced May 18, 2026
This was referenced May 26, 2026
youknowone
pushed a commit
that referenced
this pull request
Sep 16, 2026
* Add macro for type check function in c-api
* Add `fn` to macro
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|