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

Better get typing for basic list usage #183

Closed DeviousStoat closed 1 year ago

DeviousStoat commented 1 year ago

get is very hard to type but a very nice simple usage of the function is to maybe get a value from a list without worrying about index errors, similarly to get method for dict. Since using the function on a list with an int path is unequivocal, this usage can be typed. This is the goal of this PR.

coveralls commented 1 year ago

Coverage Status

Coverage: 100.0%. Remained the same when pulling b57ede9f24f71ff3b76f3fd5b6c17be2ba419c28 on DeviousStoat:get-list into a0483e4663c2ad43aa78628f82bd08de267d2b48 on dgilland:develop.

dgilland commented 1 year ago

@DeviousStoat One thing I realized with the getis that it supports any object. If the passed in object is not a dict or list, then it falls back to using getattr() on the object.

dgilland commented 1 year ago

That also means that anything that is using get may need to support a non-dict/list argument(s) (e.g. invoke can invoke a method on any object).