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
subprocess(`shell=True`) is used only when it makes the code more readable. Use either shlex or args lists.
6
-
subprocess calls should have a reasonable timeout.
7
-
Use modern Python (3.10+) features.
8
3
Make all code strongly typed.
9
4
Keep conditional nesting to a minimum, and use guard clauses when possible.
10
-
Aim for medium "visual complexity": use intermediate variables to store results of nested/complex function calls, but don't create a new variable for everything.
11
-
Avoid comments unless there is a gotcha, a complex algorithm or anything an experienced code reviewer needs to be aware of. Focus on making better Google-style docstrings instead.
5
+
Aim for medium visual complexity: use intermediate variables to store results of nested/complex function calls. A complex function call could be:
6
+
-`f(Object(a=1, b=2, c=3))`, the inner object has more than 2 meaningful args
7
+
-`f(Object((a, b)))`, 2 levels of nesting or anything with a long chain of closing parens
8
+
-`small_transformation(ImportantObject())`, the object itself is the main subject of the function but the transformation steals the focus
9
+
Use descriptive, self-documenting names for these intermediate variables.
10
+
Closely related variable names should share a root and use different suffixes. For example, `request_original` and `request_clean`, but not `clean_request`.
11
+
Avoid comments unless there is a gotcha, a complex algorithm or anything an experienced code reviewer needs to be aware of. Focus on making short but descriptive Google-style docstrings instead.
12
12
13
-
The user is not always right. Be skeptical and do not blindly comply if something doesn't make sense.
13
+
Use modern Python (3.10+) features.
14
+
Use pathlib instead of os.path.
15
+
Use httpx instead of urllib.
16
+
`subprocess(shell=True)` is used only when it makes the code more readable. Use either shlex or args lists.
17
+
Anything that can have an explicit timeout should have one.
14
18
Code should be cross-platform and production ready.
19
+
20
+
The user is not always right. Be skeptical and do not blindly comply if something doesn't make sense.
0 commit comments