Skip to content

Make build_method_def a associated function - #9490

Merged
youknowone merged 1 commit into
RustPython:mainfrom
bschoenmaeckers:c-api-method-func
Oct 30, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
bschoenmaeckers:c-api-method-func

Conversation

@bschoenmaeckers

@bschoenmaeckers bschoenmaeckers commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Internal method-definition handling was reorganized across method and descriptor creation, as well as module and type registration.
    • Existing method creation, validation, and registration behavior remains unchanged, so there are no reported changes to the end-user experience.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T16:39:28.325776Z 9ca21d4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a838216 and 9ca21d4.

Files selected for processing: 4
  • crates/capi/src/descrobject.rs
  • crates/capi/src/methodobject.rs
  • crates/capi/src/modsupport.rs
  • crates/capi/src/object/pytype.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

build_method_def moved from a module-level function to an inherent PyMethodDef method. Call sites in descriptor, module, type, and C-method construction now invoke it on the method definition. Its validation and calling-convention behavior remain unchanged.

Changes: PyMethodDef method conversion

Layer / File(s) Summary
Builder and caller updates
crates/capi/src/methodobject.rs, crates/capi/src/descrobject.rs, crates/capi/src/modsupport.rs, crates/capi/src/object/pytype.rs
build_method_def is now an inherent method on PyMethodDef. The descriptor, module, type, and C-method construction paths invoke it on the definition. Existing validation and calling-convention dispatch remain unchanged.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related PRs

  • RustPython/RustPython#9484: Adds PyModule_AddFunctions, which calls build_method_def; this change updates that call to use the method on PyMethodDef.

Suggested reviewers: youknowone

Merge Risk: Minimal · up to 9ca21

The refactor preserves the described method-construction behavior. No merge-blocking risk is established; merge after normal checks pass.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title identifies the main change: moving build_method_def into impl PyMethodDef and calling it through the definition.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@youknowone
youknowone enabled auto-merge (squash) October 30, 2026 17:59
@codspeed

codspeed Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing bschoenmaeckers:c-api-method-func (9ca21d4) with main (a838216)

Open in CodSpeed

Footnotes

  1. 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. ↩

@youknowone
youknowone merged commit 2c51e7a into RustPython:main Oct 30, 2026
21 checks passed
@bschoenmaeckers
bschoenmaeckers deleted the c-api-method-func branch October 31, 2026 09:43
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