dgilland / pydash

The kitchen sink of Python utility libraries for doing "stuff" in a functional way. Based on the Lo-Dash Javascript library.
http://pydash.readthedocs.io
MIT License
1.28k stars 89 forks source link

Add argcount to the function wrappers #215

Closed DeviousStoat closed 5 months ago

DeviousStoat commented 5 months ago

fixes #210

since we do not know in advance what the function will be in the functon wrappers, the __call__ method is usually defined with the (*args, **kwargs) signature. however at runtime, when the wrapper is instanciated we know what the wrapped function is and we can return an argcount in most cases.

This PR adds the _argcount value to the function wrapper when possible, simply returning the argcount of the wrapped function when appropriate or with a few adjustments when needed. This way they can be used nicely with other functions that takes predicate like in the example in the issue linked above.

coveralls commented 5 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling f7e402bceef64d2a8a62ac90e1e3856d915482e3 on DeviousStoat:add-argcount-to-function-wrappers into 2a2fb8e58873de6f75a08927aaad653ebfa1fb97 on dgilland:develop.