ioces / toshling

a Python client library for the Toshl API
MIT License
4 stars 1 forks source link

Enhancement: consider using dataclasses or named tuples instead of dictionary for api_methods in generate.py #3

Open jfthuong opened 2 years ago

jfthuong commented 2 years ago

It is hard to perform efficient code linting and typing with code like this in generate.py:

api_method = {'method': method, 'href': href, 'argument': arg, 'return': ret}

We could use instead either:

Dataclasses are easier to implement and add type hints, but they force compatibility to Python 3.7 and above (for this file at least, which is only used for dev).

Does it look like a fair suggestion?

m-schubert commented 2 years ago

A vote for dataclasses from me. I'm not a huge fan of named tuples, and I don't mind the development dependency on Python 3.7. If it makes it easier, feel free to split the generation code out into its own module. It's a very monolithic script at the moment.

jfthuong commented 2 years ago

I love dataclasses (and also never really liked NamedTuple... always felt it was an alternative before dataclasses arrived)

m-schubert commented 2 years ago

@jfthuong, were you going to create a PR for this one?