Wikimedia Cloud Services team/Python coding

From Wikitech
Jump to navigation Jump to search

This is a proposal to start the conversation for now.

In the interest of clean, readable code across the team, it is common practice by development groups to share formatting and other development practices in order to facilitate collaboration. A common example is shared linter settings, like what is used in operations/puppet for puppet-lint.

This is also intended as Team Practices, not an overall standard. The Foundation has several materials on that in a more general sense already, such as https://www.mediawiki.org/wiki/Manual:Coding_conventions/Python or https://wikitech.wikimedia.org/wiki/PythonStyleGuide (merged into the former to prevent duplication/forking).

We write a lot of python, so it seems like that would be the place to introduce some common practices for the WMCS team.

Formatting

While PEP8 provides most of this, and the flake8 linter enforces it on CI, flake8 is pretty liberal, and formatting is hardly consistent. Using the auto-formatter black provides a more narrow interpretation of PEP8, can be integrated into all of our text editors, and makes the reasoning of the code stand out over the format. Black is configurable if we have disagreements with its defaults.

To be continued...

Configuration Data

Something about when using a config file vs command line parameters is preferred...