Skip to content

Infer curry arity for callable objects and constructors - #463

Merged
dgilland merged 2 commits into
dgilland:developfrom
anticipate218:fix/curry-callable-arity
Nov 15, 2026
Merged

dgilland merged 2 commits into
dgilland:developfrom
anticipate218:fix/curry-callable-arity

Conversation

@anticipate218

@anticipate218 anticipate218 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Callable instances and class constructors with two positional parameters are currently inferred to need three arguments. For example, if an instance implements __call__(self, left, right), curry(instance)(1)(2) returns another curry wrapper instead of invoking it. The extra argument count can also make a partially curried instance consume an unwanted collection index when used with map_.

Use the public signature for fixed positional callables so implicitly supplied receivers are excluded. Preserve getfullargspec's existing treatment of wrappers with follow_wrapped=False; explicit arity and inference for keyword-only or variadic signatures keep their current behavior. This extends the bound-method fix in #365 to callable instances and constructors, and updates the previous compatibility assertion that pinned a callable instance's arity to three.

Tests cover both curry directions, positional-only callable instances, regular and inherited constructors, zero/default parameters, explicit arity, collection callbacks, and decorated function signatures. The required contributor entry and a changelog entry are included.

Validation on Windows:

  • Before the production change, the selected curry tests had 8 failures and 33 passes. After the change, all 41 passed.
  • Python 3.13.5: 3,332 unit tests and doctests passed, with 100% statement coverage.
  • Python 3.11.18, using the built wheel: 3,332 unit tests and doctests passed, with 100% statement coverage. Its 17 installed package files match the tested source and wheel.
  • Repository-wide Ruff lint/format checks and mypy over src/pydash, tests, and tasks.py passed. Strict Sphinx documentation and sdist/wheel builds passed. The regenerated chaining stub matches the checked-in Git blob after CRLF normalization.
  • The unit/doctest runs retain inv test's default exclusion of tests/pytest_mypy_testing. No tracked files changed during the final test runs.

The native inv ci entry point stops because it requests a PTY unsupported on Windows; the corresponding build, documentation, lint, type, generated-stub, and test commands were run individually. Python 3.10/3.12/3.14 and other operating systems were not tested locally.

AI assistance: OpenAI Codex assisted with investigation, implementation, and local verification.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — anticipate218:fix/curry-callable-arity into dgilland:develop

@dgilland
dgilland merged commit e8ea6b6 into dgilland:develop Nov 15, 2026
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