Closed FelixSchwarz closed 1 year ago
I haven't had a chance to fully look this over, but I think something like this would be great and definitely improve DX.
I'd also propose we always use function names that match MJML upstream (where possible). e.g. I think we should always use self.getAttribute
(we also use self.get_attr
in many places). This makes converting the upstream code to Python a little easier.
In the beginning I also thought that matching the function name 1:1 would be the best option. After working a bit in the mjml source code I decided that camel case is just too painful as it looks too alien in Python. In the end if all camel-case names are converted into snake-case the mental mapping should be pretty fast as well (e.g. fooBar()
→ foo_bar()
).
With .get_attr()
I went down a slippery slope: I found that "in that special case" .get_attribute()
was pretty long and a shorter method name makes it easier to see what output data is created instead. I could see that we should .get_attribute()
but I really would like to use snake-case instead of camel-case.
As @caseyjhol noticed the code currently reflects a lot of my personal preferences. In order to get some consistency I thought about adding ruff via pre-commit with a somewhat minimal configuration.
Currently this is not enabled in CI but I just want to know if this is a good idea or not.
@caseyjhol What is your opinion on this?