You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+33-8Lines changed: 33 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ A few specific differences from Google style (or black)
13
13
2. Hanging indents are always preferred, please avoid aligning arguments with closing brackets or braces.
14
14
15
15
Example, from Google guide, but this is a NO here:
16
-
```
16
+
```python
17
17
# Aligned with opening delimiter.
18
18
foo = long_function_name(var_one, var_two,
19
19
var_three, var_four)
@@ -29,7 +29,7 @@ Example, from Google guide, but this is a NO here:
29
29
```
30
30
This is YES:
31
31
32
-
```
32
+
```python
33
33
# 4-space hanging indent; nothing on first line,
34
34
# closing parenthesis on a new line.
35
35
foo = long_function_name(
@@ -49,15 +49,40 @@ This is YES:
49
49
}
50
50
```
51
51
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
+
defvery_important_function(
55
+
template: str,
56
+
*variables,
57
+
file: os.PathLike,
58
+
engine: str,
59
+
header: bool=True,
60
+
debug: bool=False,
61
+
):
62
+
withopen(file, "w") as f:
63
+
...
56
64
```
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
+
defvery_important_function(
70
+
template: str,
71
+
*variables,
72
+
file: os.PathLike,
73
+
engine: str,
74
+
header: bool=True,
75
+
debug: bool=False,
76
+
):
77
+
withopen(file, "w") as f:
78
+
...
58
79
```
59
80
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.
61
86
62
87
PR with pure formatting / style fixes will be accepted but only in isolation from functional changes, best to ask before starting such a change.
0 commit comments