diff options
| -rw-r--r-- | .flake8 | 3 | ||||
| -rw-r--r-- | .pylintrc | 298 | ||||
| -rw-r--r-- | SUBMITTING_PATCHES.md | 28 |
3 files changed, 27 insertions, 302 deletions
diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..45ab6562 --- /dev/null +++ b/.flake8 | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | [flake8] | ||
| 2 | max-line-length=80 | ||
| 3 | ignore=E111,E114,E402 | ||
diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 413d66a1..00000000 --- a/.pylintrc +++ /dev/null | |||
| @@ -1,298 +0,0 @@ | |||
| 1 | # lint Python modules using external checkers. | ||
| 2 | # | ||
| 3 | # This is the main checker controling the other ones and the reports | ||
| 4 | # generation. It is itself both a raw checker and an astng checker in order | ||
| 5 | # to: | ||
| 6 | # * handle message activation / deactivation at the module level | ||
| 7 | # * handle some basic but necessary stats'data (number of classes, methods...) | ||
| 8 | # | ||
| 9 | [MASTER] | ||
| 10 | |||
| 11 | # Specify a configuration file. | ||
| 12 | #rcfile= | ||
| 13 | |||
| 14 | # Python code to execute, usually for sys.path manipulation such as | ||
| 15 | # pygtk.require(). | ||
| 16 | #init-hook= | ||
| 17 | |||
| 18 | # Profiled execution. | ||
| 19 | profile=no | ||
| 20 | |||
| 21 | # Add <file or directory> to the black list. It should be a base name, not a | ||
| 22 | # path. You may set this option multiple times. | ||
| 23 | ignore=SVN | ||
| 24 | |||
| 25 | # Pickle collected data for later comparisons. | ||
| 26 | persistent=yes | ||
| 27 | |||
| 28 | # Set the cache size for astng objects. | ||
| 29 | cache-size=500 | ||
| 30 | |||
| 31 | # List of plugins (as comma separated values of python modules names) to load, | ||
| 32 | # usually to register additional checkers. | ||
| 33 | load-plugins= | ||
| 34 | |||
| 35 | |||
| 36 | [MESSAGES CONTROL] | ||
| 37 | |||
| 38 | # Enable only checker(s) with the given id(s). This option conflicts with the | ||
| 39 | # disable-checker option | ||
| 40 | #enable-checker= | ||
| 41 | |||
| 42 | # Enable all checker(s) except those with the given id(s). This option | ||
| 43 | # conflicts with the enable-checker option | ||
| 44 | #disable-checker= | ||
| 45 | |||
| 46 | # Enable all messages in the listed categories. | ||
| 47 | #enable-msg-cat= | ||
| 48 | |||
| 49 | # Disable all messages in the listed categories. | ||
| 50 | #disable-msg-cat= | ||
| 51 | |||
| 52 | # Enable the message(s) with the given id(s). | ||
| 53 | enable=RP0004 | ||
| 54 | |||
| 55 | # Disable the message(s) with the given id(s). | ||
| 56 | disable=C0326,R0903,R0912,R0913,R0914,R0915,W0141,C0111,C0103,W0603,W0703,R0911,C0301,C0302,R0902,R0904,W0142,W0212,E1101,E1103,R0201,W0201,W0122,W0232,RP0001,RP0003,RP0101,RP0002,RP0401,RP0701,RP0801,F0401,E0611,R0801,I0011 | ||
| 57 | |||
| 58 | [REPORTS] | ||
| 59 | |||
| 60 | # set the output format. Available formats are text, parseable, colorized, msvs | ||
| 61 | # (visual studio) and html | ||
| 62 | output-format=text | ||
| 63 | |||
| 64 | # Put messages in a separate file for each module / package specified on the | ||
| 65 | # command line instead of printing them on stdout. Reports (if any) will be | ||
| 66 | # written in a file name "pylint_global.[txt|html]". | ||
| 67 | files-output=no | ||
| 68 | |||
| 69 | # Tells whether to display a full report or only the messages | ||
| 70 | reports=yes | ||
| 71 | |||
| 72 | # Python expression which should return a note less than 10 (10 is the highest | ||
| 73 | # note).You have access to the variables errors warning, statement which | ||
| 74 | # respectivly contain the number of errors / warnings messages and the total | ||
| 75 | # number of statements analyzed. This is used by the global evaluation report | ||
| 76 | # (R0004). | ||
| 77 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) | ||
| 78 | |||
| 79 | # Add a comment according to your evaluation note. This is used by the global | ||
| 80 | # evaluation report (R0004). | ||
| 81 | comment=no | ||
| 82 | |||
| 83 | # checks for | ||
| 84 | # * unused variables / imports | ||
| 85 | # * undefined variables | ||
| 86 | # * redefinition of variable from builtins or from an outer scope | ||
| 87 | # * use of variable before assigment | ||
| 88 | # | ||
| 89 | [VARIABLES] | ||
| 90 | |||
| 91 | # Tells whether we should check for unused import in __init__ files. | ||
| 92 | init-import=no | ||
| 93 | |||
| 94 | # A regular expression matching names used for dummy variables (i.e. not used). | ||
| 95 | dummy-variables-rgx=_|dummy | ||
| 96 | |||
| 97 | # List of additional names supposed to be defined in builtins. Remember that | ||
| 98 | # you should avoid to define new builtins when possible. | ||
| 99 | additional-builtins= | ||
| 100 | |||
| 101 | |||
| 102 | # try to find bugs in the code using type inference | ||
| 103 | # | ||
| 104 | [TYPECHECK] | ||
| 105 | |||
| 106 | # Tells whether missing members accessed in mixin class should be ignored. A | ||
| 107 | # mixin class is detected if its name ends with "mixin" (case insensitive). | ||
| 108 | ignore-mixin-members=yes | ||
| 109 | |||
| 110 | # List of classes names for which member attributes should not be checked | ||
| 111 | # (useful for classes with attributes dynamicaly set). | ||
| 112 | ignored-classes=SQLObject | ||
| 113 | |||
| 114 | # When zope mode is activated, consider the acquired-members option to ignore | ||
| 115 | # access to some undefined attributes. | ||
| 116 | zope=no | ||
| 117 | |||
| 118 | # List of members which are usually get through zope's acquisition mecanism and | ||
| 119 | # so shouldn't trigger E0201 when accessed (need zope=yes to be considered). | ||
| 120 | acquired-members=REQUEST,acl_users,aq_parent | ||
| 121 | |||
| 122 | |||
| 123 | # checks for : | ||
| 124 | # * doc strings | ||
| 125 | # * modules / classes / functions / methods / arguments / variables name | ||
| 126 | # * number of arguments, local variables, branchs, returns and statements in | ||
| 127 | # functions, methods | ||
| 128 | # * required module attributes | ||
| 129 | # * dangerous default values as arguments | ||
| 130 | # * redefinition of function / method / class | ||
| 131 | # * uses of the global statement | ||
| 132 | # | ||
| 133 | [BASIC] | ||
| 134 | |||
| 135 | # Required attributes for module, separated by a comma | ||
| 136 | required-attributes= | ||
| 137 | |||
| 138 | # Regular expression which should only match functions or classes name which do | ||
| 139 | # not require a docstring | ||
| 140 | no-docstring-rgx=_main|__.*__ | ||
| 141 | |||
| 142 | # Regular expression which should only match correct module names | ||
| 143 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ | ||
| 144 | |||
| 145 | # Regular expression which should only match correct module level names | ||
| 146 | const-rgx=(([A-Z_][A-Z1-9_]*)|(__.*__))|(log)$ | ||
| 147 | |||
| 148 | # Regular expression which should only match correct class names | ||
| 149 | class-rgx=[A-Z_][a-zA-Z0-9]+$ | ||
| 150 | |||
| 151 | # Regular expression which should only match correct function names | ||
| 152 | function-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
| 153 | |||
| 154 | # Regular expression which should only match correct method names | ||
| 155 | method-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
| 156 | |||
| 157 | # Regular expression which should only match correct instance attribute names | ||
| 158 | attr-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
| 159 | |||
| 160 | # Regular expression which should only match correct argument names | ||
| 161 | argument-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
| 162 | |||
| 163 | # Regular expression which should only match correct variable names | ||
| 164 | variable-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
| 165 | |||
| 166 | # Regular expression which should only match correct list comprehension / | ||
| 167 | # generator expression variable names | ||
| 168 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ | ||
| 169 | |||
| 170 | # Good variable names which should always be accepted, separated by a comma | ||
| 171 | good-names=i,j,k,ex,Run,_,e,d1,d2,v,f,l,d | ||
| 172 | |||
| 173 | # Bad variable names which should always be refused, separated by a comma | ||
| 174 | bad-names=foo,bar,baz,toto,tutu,tata | ||
| 175 | |||
| 176 | # List of builtins function names that should not be used, separated by a comma | ||
| 177 | bad-functions=map,filter,apply,input | ||
| 178 | |||
| 179 | |||
| 180 | # checks for sign of poor/misdesign: | ||
| 181 | # * number of methods, attributes, local variables... | ||
| 182 | # * size, complexity of functions, methods | ||
| 183 | # | ||
| 184 | [DESIGN] | ||
| 185 | |||
| 186 | # Maximum number of arguments for function / method | ||
| 187 | max-args=5 | ||
| 188 | |||
| 189 | # Maximum number of locals for function / method body | ||
| 190 | max-locals=15 | ||
| 191 | |||
| 192 | # Maximum number of return / yield for function / method body | ||
| 193 | max-returns=6 | ||
| 194 | |||
| 195 | # Maximum number of branch for function / method body | ||
| 196 | max-branchs=12 | ||
| 197 | |||
| 198 | # Maximum number of statements in function / method body | ||
| 199 | max-statements=50 | ||
| 200 | |||
| 201 | # Maximum number of parents for a class (see R0901). | ||
| 202 | max-parents=7 | ||
| 203 | |||
| 204 | # Maximum number of attributes for a class (see R0902). | ||
| 205 | max-attributes=20 | ||
| 206 | |||
| 207 | # Minimum number of public methods for a class (see R0903). | ||
| 208 | min-public-methods=2 | ||
| 209 | |||
| 210 | # Maximum number of public methods for a class (see R0904). | ||
| 211 | max-public-methods=30 | ||
| 212 | |||
| 213 | |||
| 214 | # checks for | ||
| 215 | # * external modules dependencies | ||
| 216 | # * relative / wildcard imports | ||
| 217 | # * cyclic imports | ||
| 218 | # * uses of deprecated modules | ||
| 219 | # | ||
| 220 | [IMPORTS] | ||
| 221 | |||
| 222 | # Deprecated modules which should not be used, separated by a comma | ||
| 223 | deprecated-modules=regsub,string,TERMIOS,Bastion,rexec | ||
| 224 | |||
| 225 | # Create a graph of every (i.e. internal and external) dependencies in the | ||
| 226 | # given file (report R0402 must not be disabled) | ||
| 227 | import-graph= | ||
| 228 | |||
| 229 | # Create a graph of external dependencies in the given file (report R0402 must | ||
| 230 | # not be disabled) | ||
| 231 | ext-import-graph= | ||
| 232 | |||
| 233 | # Create a graph of internal dependencies in the given file (report R0402 must | ||
| 234 | # not be disabled) | ||
| 235 | int-import-graph= | ||
| 236 | |||
| 237 | |||
| 238 | # checks for : | ||
| 239 | # * methods without self as first argument | ||
| 240 | # * overridden methods signature | ||
| 241 | # * access only to existant members via self | ||
| 242 | # * attributes not defined in the __init__ method | ||
| 243 | # * supported interfaces implementation | ||
| 244 | # * unreachable code | ||
| 245 | # | ||
| 246 | [CLASSES] | ||
| 247 | |||
| 248 | # List of interface methods to ignore, separated by a comma. This is used for | ||
| 249 | # instance to not check methods defines in Zope's Interface base class. | ||
| 250 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by | ||
| 251 | |||
| 252 | # List of method names used to declare (i.e. assign) instance attributes. | ||
| 253 | defining-attr-methods=__init__,__new__,setUp | ||
| 254 | |||
| 255 | |||
| 256 | # checks for similarities and duplicated code. This computation may be | ||
| 257 | # memory / CPU intensive, so you should disable it if you experiments some | ||
| 258 | # problems. | ||
| 259 | # | ||
| 260 | [SIMILARITIES] | ||
| 261 | |||
| 262 | # Minimum lines number of a similarity. | ||
| 263 | min-similarity-lines=4 | ||
| 264 | |||
| 265 | # Ignore comments when computing similarities. | ||
| 266 | ignore-comments=yes | ||
| 267 | |||
| 268 | # Ignore docstrings when computing similarities. | ||
| 269 | ignore-docstrings=yes | ||
| 270 | |||
| 271 | |||
| 272 | # checks for: | ||
| 273 | # * warning notes in the code like FIXME, XXX | ||
| 274 | # * PEP 263: source code with non ascii character but no encoding declaration | ||
| 275 | # | ||
| 276 | [MISCELLANEOUS] | ||
| 277 | |||
| 278 | # List of note tags to take in consideration, separated by a comma. | ||
| 279 | notes=FIXME,XXX,TODO | ||
| 280 | |||
| 281 | |||
| 282 | # checks for : | ||
| 283 | # * unauthorized constructions | ||
| 284 | # * strict indentation | ||
| 285 | # * line length | ||
| 286 | # * use of <> instead of != | ||
| 287 | # | ||
| 288 | [FORMAT] | ||
| 289 | |||
| 290 | # Maximum number of characters on a single line. | ||
| 291 | max-line-length=80 | ||
| 292 | |||
| 293 | # Maximum number of lines in a module | ||
| 294 | max-module-lines=1000 | ||
| 295 | |||
| 296 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 | ||
| 297 | # tab). In repo it is 2 spaces. | ||
| 298 | indent-string=' ' | ||
diff --git a/SUBMITTING_PATCHES.md b/SUBMITTING_PATCHES.md index 085ae06a..07f76616 100644 --- a/SUBMITTING_PATCHES.md +++ b/SUBMITTING_PATCHES.md | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | - Make small logical changes. | 3 | - Make small logical changes. |
| 4 | - Provide a meaningful commit message. | 4 | - Provide a meaningful commit message. |
| 5 | - Check for coding errors with pylint | 5 | - Check for coding errors and style nits with pyflakes and flake8 |
| 6 | - Make sure all code is under the Apache License, 2.0. | 6 | - Make sure all code is under the Apache License, 2.0. |
| 7 | - Publish your changes for review. | 7 | - Publish your changes for review. |
| 8 | - Make corrections if requested. | 8 | - Make corrections if requested. |
| @@ -36,12 +36,32 @@ If your description starts to get too long, that's a sign that you | |||
| 36 | probably need to split up your commit to finer grained pieces. | 36 | probably need to split up your commit to finer grained pieces. |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | ## Check for coding errors with pylint | 39 | ## Check for coding errors and style nits with pyflakes and flake8 |
| 40 | 40 | ||
| 41 | Run pylint on changed modules using the provided configuration: | 41 | ### Coding errors |
| 42 | 42 | ||
| 43 | pylint --rcfile=.pylintrc file.py | 43 | Run `pyflakes` on changed modules: |
| 44 | 44 | ||
| 45 | pyflakes file.py | ||
| 46 | |||
| 47 | Ideally there should be no new errors or warnings introduced. | ||
| 48 | |||
| 49 | ### Style violations | ||
| 50 | |||
| 51 | Run `flake8` on changes modules: | ||
| 52 | |||
| 53 | flake8 file.py | ||
| 54 | |||
| 55 | Note that repo generally follows [Google's python style guide] | ||
| 56 | (https://google.github.io/styleguide/pyguide.html) rather than [PEP 8] | ||
| 57 | (https://www.python.org/dev/peps/pep-0008/), so it's possible that | ||
| 58 | the output of `flake8` will be quite noisy. It's not mandatory to | ||
| 59 | avoid all warnings, but at least the maximum line length should be | ||
| 60 | followed. | ||
| 61 | |||
| 62 | If there are many occurrences of the same warning that cannot be | ||
| 63 | avoided without going against the Google style guide, these may be | ||
| 64 | suppressed in the included `.flake8` file. | ||
| 45 | 65 | ||
| 46 | ## Check the license | 66 | ## Check the license |
| 47 | 67 | ||
