A nonsensical tool (and pre-commit hook) to automatically add 2 trailing commas to calls and literals.
If you want your code to raise neat SytnaxError
s, this tool is for you!
pip install add-2trailing-commas
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/thisanthonywritesbettercode/add-2trailing-commas
rev: v3.2.0
hooks:
- id: add-2trailing-commas
# Sample of *ideal* syntax
function_call(
argument,
5 ** 5,
kwarg=foo,,
)
- the initial paren is at the end of the line
- each argument is indented one level further than the function name
- the last parameter (unless the call contains an unpacking
(
*args
/**kwargs
)) has a 2 trailing commas (What a beauty!)
This has the following benefits:
- none.