trafaret icon indicating copy to clipboard operation
trafaret copied to clipboard

Support for Set in addition to List and Tuple?

Open proofit404 opened this issue 4 years ago • 3 comments

Hi, thanks for the useful package!

Is there any technical reason behind Set support absence?

Or I'm a very first person who actually needs it?

If it's missed because no one needs it yet, and maintainers are not against it, I would like to provide pull request with such implementation. Documentation and tests included.

Hopefully, new minor release would be issued after this contribution.

Thoughts?

Regards, Artem.

proofit404 avatar Dec 12 '21 20:12 proofit404

I'm not against, of course. Did not include it, because generally, when you get something from internet in json, it is definitely does not include sets, instead it has list/array, and then you check that members of this set is uniq and then call set, like t.List() & uniq & set. To check python structs, you can use t.Type(set). Not sure what is you case, I'm open to new contributions.

Deepwalker avatar Dec 13 '21 08:12 Deepwalker

I use trafaret as normalization library in the service layer of my application.

For example, here and there, now and then.

So, in my case it supposed to be used for:

  • value is a set of elements of right type
  • value could be normalized to set
  • items of value could be normalized to specified type

If I understand correctly, it could be expressed already but would require a complicated expression instead of just Set.

proofit404 avatar Dec 13 '21 11:12 proofit404

In this case I vote for Set trafaret.

Deepwalker avatar Dec 13 '21 11:12 Deepwalker