Skip to content

Add type name c-api functions#7925

Merged
youknowone merged 1 commit into
RustPython:mainfrom
bschoenmaeckers:c-api-more-type
May 19, 2026
Merged

Add type name c-api functions#7925
youknowone merged 1 commit into
RustPython:mainfrom
bschoenmaeckers:c-api-more-type

Conversation

@bschoenmaeckers
Copy link
Copy Markdown
Contributor

@bschoenmaeckers bschoenmaeckers commented May 19, 2026

Summary by CodeRabbit

  • New Features
    • Added three new C API functions for type objects (PyType_GetName, PyType_GetQualName, PyType_GetFullyQualifiedName) to retrieve type naming information for use in C extensions and external integrations.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

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.

@youknowone youknowone merged commit 26f5bbf into RustPython:main May 19, 2026
26 checks passed
@bschoenmaeckers bschoenmaeckers deleted the c-api-more-type branch May 19, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants