◐ Shell
clean mode source ↗

Add type name c-api functions by bschoenmaeckers · Pull Request #7925 · RustPython/RustPython

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: 4b9f5102-9113-4455-973c-87faff6e7ecb

📥 Commits

Reviewing files that changed from the base of the PR and between d8dee81 and ee3d5a5.

📒 Files selected for processing (1)
  • crates/capi/src/object.rs

📝 Walkthrough

Walkthrough

This PR adds three new C API functions to expose Python type object names: PyType_GetName, PyType_GetQualName, and PyType_GetFullyQualifiedName. The functions retrieve type metadata from the VM context and construct fully qualified names conditionally based on module.

Changes

Type name accessor functions

Layer / File(s) Summary
Type name accessor functions
crates/capi/src/object.rs
PyType_GetName and PyType_GetQualName directly return __name__ and __qualname__ attributes. PyType_GetFullyQualifiedName conditionally prepends __module__ to __qualname__, omitting the module prefix when it equals "builtins".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • RustPython/RustPython#7871: Both PRs extend C API type functions in crates/capi/src/object.rs using the current VM context, though targeting different type capabilities.

Suggested reviewers

  • youknowone

Poem

🐰 Three functions hopping into view,
Names of types both old and new,
Builtins skip their module dance,
While others get their full advance,
The C API hops along! 🎉

🚥 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 three new C-API functions (PyType_GetName, PyType_GetQualName, PyType_GetFullyQualifiedName) for accessing Python type object names.
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.