diff options
author | kjellander <kjellander@webrtc.org> | 2017-04-12 22:43:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2017-04-13 05:43:38 +0000 |
commit | 38c65c8fb481e2ee209ebc1b52460894787f7ae3 (patch) | |
tree | ec6d2104e8b6868db2c6529ccbd27c893b17a0f5 | |
parent | 6c84c279cd9305294b8c1e2b57279533df372bd1 (diff) | |
download | webrtc-38c65c8fb481e2ee209ebc1b52460894787f7ae3.tar.gz |
Update pylintrc to catch more style violations.
The current PyLint configuration doesn't catch violations
to the Chromium Python Style Guide in a good way.
This change adds mostly the correct style regex for functions
and methods, with most content copied from
https://cs.chromium.org/chromium/tools/depot_tools/pylintrc
and (since the former disables invalid-name)
https://cs.chromium.org/chromium/src/third_party/chromite/pylintrc
Many settings are the defaults, but are now more explicit to make it
easier to find them for our users.
Also convert the previous one-line list of disabled lint check into
a one-per-line list instead.
Add import-error to the list of disabled lint checks.
This CL depends on https://codereview.webrtc.org/2812273002/
to be landed first in order to not produce a lot of errors.
BUG=webrtc:7303
NOTRY=True
TESTED=git cl presubmit passing when tested in
combination with https://codereview.webrtc.org/2812273002/
TBR=niklas.enbom@webrtc.org
Review-Url: https://codereview.webrtc.org/2737963003
Cr-Commit-Position: refs/heads/master@{#17685}
-rw-r--r-- | OWNERS | 1 | ||||
-rwxr-xr-x | PRESUBMIT.py | 5 | ||||
-rw-r--r-- | pylintrc | 203 |
3 files changed, 204 insertions, 5 deletions
@@ -10,4 +10,5 @@ per-file *.py=kjellander@webrtc.org per-file AUTHORS=* per-file BUILD.gn=kjellander@webrtc.org per-file DEPS=* +per-file pylintrc=kjellander@webrtc.org per-file WATCHLISTS=* diff --git a/PRESUBMIT.py b/PRESUBMIT.py index efa80fab4f..24eff148e8 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -526,6 +526,7 @@ def _CommonChecks(input_api, output_api): black_list=(r'^base[\\\/].*\.py$', r'^build[\\\/].*\.py$', r'^buildtools[\\\/].*\.py$', + r'^infra[\\\/].*\.py$', r'^ios[\\\/].*\.py$', r'^out.*[\\\/].*\.py$', r'^testing[\\\/].*\.py$', @@ -535,10 +536,6 @@ def _CommonChecks(input_api, output_api): r'^tools-webrtc[\\\/]mb[\\\/].*\.py$', r'^tools-webrtc[\\\/]valgrind[\\\/].*\.py$', r'^xcodebuild.*[\\\/].*\.py$',), - disabled_warnings=['F0401', # Failed to import x - 'E0611', # No package y in x - 'W0232', # Class has no __init__ method - ], pylintrc='pylintrc')) # TODO(nisse): talk/ is no more, so make below checks simpler? @@ -1,8 +1,46 @@ +# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# This file is mostly based on the contents of +# https://cs.chromium.org/chromium/tools/depot_tools/pylintrc +# and (since the above doesn't properly support naming style checks) +# https://cs.chromium.org/chromium/src/third_party/chromite/pylintrc + [MESSAGES CONTROL] # Disable the message, report, category or checker with the given id(s). # TODO(kjellander): Reduce this list to as small as possible. -disable=I0010,I0011,bad-continuation,broad-except,duplicate-code,eval-used,exec-used,fixme,invalid-name,missing-docstring,no-init,no-member,too-few-public-methods,too-many-ancestors,too-many-arguments,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-lines,too-many-locals,too-many-public-methods,too-many-return-statements,too-many-statements +disable= + E0611, + I0010, + I0011, + W0232, + bad-continuation, + broad-except, + duplicate-code, + eval-used, + exec-used, + fixme, + import-error, + missing-docstring, + no-init, + no-member, + too-few-public-methods, + too-many-ancestors, + too-many-arguments, + too-many-branches, + too-many-function-args, + too-many-instance-attributes, + too-many-lines, + too-many-locals, + too-many-public-methods, + too-many-return-statements, + too-many-statements, [REPORTS] @@ -11,7 +49,170 @@ disable=I0010,I0011,bad-continuation,broad-except,duplicate-code,eval-used,exec- reports=no +[VARIABLES] + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the beginning of the name of dummy variables +# (i.e. not used). +dummy-variables-rgx=_|dummy + + +[TYPECHECK] + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamically set). +ignored-classes=hashlib,numpy + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + + [FORMAT] +# Maximum number of characters on a single line. +max-line-length=80 + +# Maximum number of lines in a module +max-module-lines=1000 + # We use two spaces for indents, instead of the usual four spaces or tab. indent-string=' ' + + +[BASIC] + +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input + +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +# (CAPS_WITH_UNDER) +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +# (CapWords) +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression which should only match correct function names +# The Chromium standard is different than PEP-8, so we need to redefine this to +# only allow: +# - CapWords +# - main: Standard for main function. +function-rgx=([A-Z_][a-zA-Z0-9]{2,60}|main)$ + +# Regular expression which should only match correct method names +# The Chromium standard is different than PEP-8, so we need to redefine this to +# only allow: +# - CapWords, starting with a capital letter. No underscores in function +# names. Can also have a "_" prefix (private method) or a "test" prefix +# (unit test). +# - Methods that look like __xyz__, which are used to do things like +# __init__, __del__, etc. +# - setUp, tearDown: For unit tests. +method-rgx=((_|test)?[A-Z][a-zA-Z0-9]{2,60}|__[a-z]+__|setUp|tearDown)$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-z_][a-z0-9_]{0,30}$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# Regular expression which should only match functions or classes name which do +# not require a docstring +no-docstring-rgx=__.*__ + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branchs=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +[CLASSES] + +# List of interface methods to ignore, separated by a comma. This is used for +# instance to not check methods defines in Zope's Interface base class. +ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,TERMIOS,Bastion,rexec + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception |