Skip to content

fix(python): recognize cdef/cpdef return-type functions in args counting - #2250

Merged
squid-protocol merged 1 commit into
mainfrom
fix/python-2238-cython-args
Aug 26, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/python-2238-cython-args

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #2238. GitGalaxy's python args rule only matched literal def/lambda — no cdef/cpdef alternative existed. A bare cdef name(...) with no return type happened to get the correct count by accident (the regex's literal def substring matches inside cdef), but the instant a C return-type token intervened (char, void, a Tempita {{...}} placeholder), that accidental adjacency broke and args fell back to 0.

Mirrors func_start's own cdef/cpdef return-type-skipping structure (already correct per #1999) for the args rule.

Evidence

Real functions in language-crucible/data/python/cython/MemoryView.pxd/.pyx, before → after:

Function Before After
get_item_pointer 0 2
copy_data_to_temp 0 2
array_cwrapper 0 5
memoryview_check 0 1
transpose_memslice 0 1
_unellipsify 0 2
memoryview_copy_contents 0 4
_copy_strided_to_strided 0 8
slice_assign_scalar 0 6

Plain def foo(a, b):, lambda x, y: ..., and the accidental-but-correct bare-cdef name(self, obj) case are all unchanged.

Verification

  • pytest tests/extraction/languages/test_python.py -q — 79 passed (3 new cases + dedicated regression test)
  • audit_check.py --ci — clean
  • crucible_check.py --mode both — drift confined to python/cython (blessed, matches the fix's intent)
  • tree_sitter_accuracy_audit.py --all --ci — clean
  • tri_comparison_chart.py --all --ci — clean

🤖 Generated with Gemini (via agy), orchestrated and independently verified by Claude Code.

Cython cdef/cpdef declarations with a C return type before the function
name (e.g. `cdef char *get_item_pointer(...)`) reported args=0 -- the
args regex only matched literal `def`/`lambda`, and previously relied on
`def`'s accidental substring match inside `cdef` itself, which breaks
the instant a return-type token intervenes. Mirrors func_start's own
cdef/cpdef return-type-skipping structure (#1999) for the args rule.

Confirmed on language-crucible's cython/MemoryView.pxd/.pyx: 9 sampled
real functions (get_item_pointer, copy_data_to_temp, array_cwrapper,
memoryview_check, transpose_memslice, _unellipsify,
memoryview_copy_contents, _copy_strided_to_strided,
slice_assign_scalar) went from args=0 to their correct nonzero counts.
Plain def/lambda and the accidental-but-correct bare-cdef case are
unaffected.

Closes #2238

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit cb2d310 into main Aug 26, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/python-2238-cython-args branch August 26, 2026 13:30
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.

python: args regex has no cdef/cpdef alternative -- reports 0 for every Cython function with a C return type

1 participant