Skip to content

methodize: keep self before position-only params - #119

Merged
thorwhalen merged 1 commit into
masterfrom
fix/118-methodize-posonly
Oct 20, 2026
Merged

thorwhalen merged 1 commit into
masterfrom
fix/118-methodize-posonly

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Closes #118.

func_to_method_func (and so methodize) prepended the instance param with instance_arg_name + method_sig. Sig addition sorts by kind, so with a position-only param left in the method, self landed after the / (e.g. def f(a, /, b) with methodize(f, bind='b') gave (a, /, self), and calling it bound the wrong argument to self).

The new _prepend_instance_param makes self position-only and first when the method signature has a position-only param; otherwise it keeps the previous instance_arg_name + sig path, so signatures without position-only params are unchanged.

Tests: new test_methodize_keeps_self_before_position_only_params (bind and default_from); full suite 870 passed, 2 xfailed. The second point of the issue (JSON-serializing an InstanceAttrDefault default in front/py2http) is a separate check, filed as a follow-up.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N5aMHWyyR5mECim15Wv8kc

func_to_method_func prepended the instance param with Sig addition, which
sorts by kind and so put `self` after the `/` when the method kept a
position-only param. The instance param is now position-only (and first)
whenever the method signature has position-only params.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 4a5cef6 into master Oct 20, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the fix/118-methodize-posonly branch October 20, 2026 18:03
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.

methodize / func_to_method_func: position-only params put self after the /

1 participant