AnemoneLabs / unmessage

Privacy enhanced instant messenger
GNU General Public License v3.0
43 stars 7 forks source link

Use attrs #34

Closed felipedau closed 7 years ago

felipedau commented 7 years ago

Feedback from @david415 suggested the use of attrs to simplify the code, make it more concise, etc.

felipedau commented 7 years ago

Hi @david415 and @meejah, I read attrs' docs and picked one of unMessage's classes to use it. Contact seemed to be a good one as it has optional attributes, typed attributes and validated attributes. The changes are in 9fceaa1d424e6bcac1a5cf7b45ae92cc5e13e367.

I chose to make type validation in the validator methods because I wanted it to raise the specific Invalid<Attr>Error, instead of TypeError.

P.S. I also saw that attrs has a nice way to represent instances for serializing, so that will help a lot when dealing with the file element, for example.

Let me know what you think.

Thanks!

felipedau commented 7 years ago

I am closing this as most of unMessage's classes have now been created with attrs. In some cases it was not possible so I opened #50 and #51.