From a67a925e1742a88ce9cf7d5f507cbd41f63df558 Mon Sep 17 00:00:00 2001 From: Ryo Chijiiwa Date: Thu, 17 Oct 2019 15:55:11 -0700 Subject: [PATCH 1/2] addition to naming section, add Function Length --- Readme.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Readme.md b/Readme.md index c62e59a..1873b70 100644 --- a/Readme.md +++ b/Readme.md @@ -180,6 +180,20 @@ class FooTestCase(TestCase): Use CapitalizedCamelCase for class names, snake_case for everything else. Use CAPITALIZED_SNAKE_CASE for global consts. See the [Google style guide](https://google.github.io/styleguide/pyguide.html#Naming) for more. + * Prefer shorter names (3 words or less) + * Don't describe code. Names are placeholders and "mind hooks". + * Don't repeat what's implied in the module name or class names. + * Do use naming to avoid ambiguity. + +## Function Length + + * Prefer short and focused functions (less than 60 lines). + * Avoid single-line functions. + * If a function exceeds 40 lines and there is an easy opportunity for refactoring, do so. + * If there are more than 3 levels of indentation, try to refactor. + +(Based on [Google Style Guide](https://google.github.io/styleguide/pyguide.html#318-function-length)) + ## Unused variables If you want to assign a value to a variable that will not be used again, name the variable either `_` (python convention) or `unused_` (less-well-known python convention). This will keep our lint checkers from complaining. From fb0692f41a067c79164703a144ffbcf9feeb7119 Mon Sep 17 00:00:00 2001 From: Ryo Chijiiwa Date: Thu, 17 Oct 2019 16:52:31 -0700 Subject: [PATCH 2/2] update break style --- Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 1873b70..7dee2b0 100644 --- a/Readme.md +++ b/Readme.md @@ -278,9 +278,9 @@ words = [ 'fox', # note the trailing comma ] -user = ( - User.objects.filter(name__icontains='joe'). - values_list('user', 'username') +user = User.objects.filter(name__icontains='joe').values_list( + 'user', + 'username' ) [{