PRUNERS / FLiT

A project to quickly detect discrepancies in floating point computation across hardware, compilers, libraries and software.
Other
36 stars 6 forks source link

Consistent python formatting #339

Open mikebentley15 opened 3 years ago

mikebentley15 commented 3 years ago

Feature Request

Description:

The python formatting currently is done by hand by the original author (myself). This is not particularly sustainable.

It may be worthwhile to look into third-party code formatting tools. The same may be true with C++, but this feature request specifically refers to the python code which is now the majority of the code (I think).

Suggested change:

This is brought on because I found a tool called python-black which easily and reproducibly formats python code. I think it's worth looking into to see if we would like to adopt this tool officially for formatting our python code in FLiT.

It may be worthwhile making it easy to automatically run this formatter as git hooks, like commits or pushes. I'd probably prefer simply enforcing the use of this formatter (if we like it) by checking in a simple unit test that running the formatter changes nothing.

Alternative approaches:

There may be other code formatters that we like, but it seems black is popular and used by big groups like Python Pandas. But if we don't like the formatting scheme, we can look into other choices.

caydenlund commented 2 years ago

Great idea. I find that code formatters help teams to focus on what matters instead of getting distracted by style inconsistencies.

For Python, there are three main formatters that I see popular in the community:

This blog post gives a nice overview of the differences.