Skip to content

Commit 30b757c

Browse files
authored
Update CONTRIBUTING.md
1 parent 234907e commit 30b757c

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

CONTRIBUTING.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A few specific differences from Google style (or black)
1313
2. Hanging indents are always preferred, please avoid aligning arguments with closing brackets or braces.
1414

1515
Example, from Google guide, but this is a NO here:
16-
```
16+
```python
1717
# Aligned with opening delimiter.
1818
foo = long_function_name(var_one, var_two,
1919
var_three, var_four)
@@ -29,7 +29,7 @@ Example, from Google guide, but this is a NO here:
2929
```
3030
This is YES:
3131

32-
```
32+
```python
3333
# 4-space hanging indent; nothing on first line,
3434
# closing parenthesis on a new line.
3535
foo = long_function_name(
@@ -49,15 +49,40 @@ This is YES:
4949
}
5050
```
5151

52-
When there is discrepancy in a given source file (there are many origins for various bits of code and not all have been updated to what I consider current goal), please follow the style in a given file.
53-
54-
In general, if you add new code, formatting it with black using the following options should result in a style that is compatible with the rest of the code base:
55-
52+
While preferred `timm` style is *mostly* compatible with Black / Ruff. Since I've been following PEP 8 style since before Black was a thing, there's one area I can't agree on, function arg indents. From a Black example this:
53+
```python
54+
def very_important_function(
55+
template: str,
56+
*variables,
57+
file: os.PathLike,
58+
engine: str,
59+
header: bool = True,
60+
debug: bool = False,
61+
):
62+
with open(file, "w") as f:
63+
...
5664
```
57-
black --skip-string-normalization --line-length 120 <path-to-file>
65+
66+
Should according to PEP 8 (https://peps.python.org/pep-0008/#indentation) have an extra level of indent on the args:
67+
68+
```python
69+
def very_important_function(
70+
template: str,
71+
*variables,
72+
file: os.PathLike,
73+
engine: str,
74+
header: bool = True,
75+
debug: bool = False,
76+
):
77+
with open(file, "w") as f:
78+
...
5879
```
5980

60-
Avoid formatting code that is unrelated to your PR though.
81+
I do like sadface though. So please don't run Black on existing files and convert all of the arg indents. Thanks!
82+
83+
When there is discrepancy in a given source file (there are many origins for various bits of code and not all have been updated to what I consider current goal), please follow the style in a given file.
84+
85+
Please avoid formatting code that is unrelated to your PR.
6186

6287
PR with pure formatting / style fixes will be accepted but only in isolation from functional changes, best to ask before starting such a change.
6388

0 commit comments

Comments
 (0)