Skip to content

Infer curry arity for fixed positional bound methods - #365

Merged
dgilland merged 2 commits into
dgilland:developfrom
mayankdhingra02:fix-bound-method-curry
Oct 27, 2026
Merged

dgilland merged 2 commits into
dgilland:developfrom
mayankdhingra02:fix-bound-method-curry

Conversation

@mayankdhingra02

Copy link
Copy Markdown
Contributor

curry() and curry_right() count the already bound receiver when inferring a Python method's arity. As a result, curry(obj.add)(1)(2) returns another curry wrapper instead of the result. A partially curried method used with map_ can also receive an unwanted collection index and raise TypeError.

Omit the implicit receiver for fixed positional bound methods. The remaining-argument count then matches the arguments callers supply, including inherited instance methods and class methods. Keyword-only and variadic signatures retain their existing inference; explicit arity and other callable types follow the existing behavior.

Regression coverage exercises both curry directions, repeated use, keyword accumulation, positional-only/default/zero-argument methods, and direct/chained collection pipelines. It also preserves static/unbound/partial/callable and keyword/variadic controls. Added the requested AUTHORS entry.

Validation:

  • All 20 new cases pass; 16 fail on the unchanged baseline.
  • Full required tox matrix on Python 3.10–3.14: package and strict documentation builds, Ruff, mypy and generated chaining-type checks all pass; each complete suite has 2,900 passing tests and 100% coverage. The unchanged Python 3.14 baseline has 2,880 passing tests and 100% coverage.

Exclude the already supplied receiver when inferring arity for Python
bound methods with fixed positional signatures. This lets both curry
directions execute after the expected caller arguments and advertise
the correct remaining argument count to collection iteratees.

Preserve existing inference for keyword-only, variadic and unrelated
callable signatures, as well as explicitly supplied arities.

Signed-off-by: Mayank Dhingra <mayankdhingra02@gmail.com>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — mayankdhingra02:fix-bound-method-curry into dgilland:develop

@dgilland dgilland left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Tests should go into the corresponding test_<module>.py file: test_functions.py (do not create a new test file)
  • Upstream has merge conflicts.

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.

3 participants