Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Nov 22, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

…objects (#3121)

* Fix callable detection to support all callable objects (functools.partial, etc)

Fixes #2008

The old implementation checked for __code__ attribute directly, which
doesn't exist for callable objects like functools.partial. This caused
an AttributeError when trying to use such objects with find_max_global
and find_min_global functions.

Changed to use Python's inspect.signature() which properly handles all
callable objects including:
- Regular functions
- Lambda functions
- functools.partial objects
- Class methods
- Any object with __call__ method

The fix includes a fallback to the old __code__ method for backward
compatibility in case inspect.signature fails for any reason.

* Update the code to loop through params.values() instead of params itself, since parameters is a dictionary-like object. The earlier code tried to access .second on the iterator, which isn’t valid when working with dict values

Signed-off-by: Samaresh Kumar Singh <[email protected]>

* Fix parameter counting to exclude *args and **kwargs

The previous code was counting VAR_POSITIONAL (*args) and VAR_KEYWORD
(**kwargs) parameters in the total count, which caused functions like
'lambda a, b, c, *args' to be counted as having 4 parameters instead
of 3. Now only regular parameters are counted, while still checking
for the presence of *args to allow variable argument functions.

Also removed test_callable_fix.py as it was causing pytest errors.

Signed-off-by: Samaresh Kumar Singh <[email protected]>

---------

Signed-off-by: Samaresh Kumar Singh <[email protected]>
@pull pull bot locked and limited conversation to collaborators Nov 22, 2025
@pull pull bot added the ⤵️ pull label Nov 22, 2025
@pull pull bot merged commit 23d73be into QSLee-Net:master Nov 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant