pyusps icon indicating copy to clipboard operation
pyusps copied to clipboard

API Suggestions

Open NickCrews opened this issue 3 years ago • 3 comments
trafficstars

Hi! Thank you for this library, it has been quite useful to me. As I've used it I've come across a couple of usage pain points and have a few ideas on how it could be improved. Some of the suggestions would be breaking for users, which is a bummer. Not sure how acceptable that would be for you. I could implement them, if you would be willing to merge my PRs. Thanks for your consideration.

Unify error behavior between single/multiple requests.

Sometimes I make requests with one address, sometimes with multiple. It is annoying that I need two different code paths to deal with the errors when an address isn't found, one where the error is thrown (single address) and one where it is just returned (multiple).

I think all errors should just be returned, and never thrown. It makes things consistent, and isn't any more code for users (in fact it may be less to check result as opposed to filtering between the various errors that could get thrown). This of course would break some users.

Don't squash info in errors

Currently, the detailed error info is just string formatted into the ValueError when an address isn't found, so it's difficult for users to recover the original error. The original info should be included somehow. This wouldn't need to be breaking.

NickCrews avatar Mar 13 '22 01:03 NickCrews

Hi Nick. Sorry for the late reply. Thanks for the feedback on this. I think if we document this well we can introduce the breaking changes as a new version. This library has been out for a few years and it's natural that it should evolve. Please send the PR over and I'll review.

Thanks.

thelinuxkid avatar Apr 05 '22 16:04 thelinuxkid

Thanks Andrés. I'll do that! I notice that this is still compatible with python2, can I get rid of support for that? It will allow me add some typing and some other nice new language constructs.

NickCrews avatar Apr 05 '22 17:04 NickCrews

That will work! Thanks Nick.

thelinuxkid avatar Apr 05 '22 18:04 thelinuxkid