Merge ~jslarraz/review-tools:fix-pylintrc into review-tools:master

Proposed by Jorge Sancho Larraz
Status: Merged
Merged at revision: c55508d020d8785c351079a4a69730d172e9455c
Proposed branch: ~jslarraz/review-tools:fix-pylintrc
Merge into: review-tools:master
Diff against target: 431 lines (+0/-425)
1 file modified
dev/null (+0/-425)
Reviewer Review Type Date Requested Status
Alex Murray Approve
Review via email: mp+461126@code.launchpad.net

Commit message

fix pylint errors

Description of the change

Currently running pylint in newer releases produces several errors. These errors are derived from the old pylintrc file that leads to configuration options that are not supported anymore.

The fix consist to minimize the options configured in pylintrc. Options not configured in this file will take the default value for each release.

After this PR the behavior in focal will be identical. For mantic there are some minimal changes (6 options in total), that after visual inspection looks reasonable, derived from the evolution of python language itself over the years and fixes introduced in pylint.

There are still some options I would like to remove from this new version of pylint, see inline comments

To post a comment you must log in.
Revision history for this message
Alex Murray (alexmurray) wrote :

Running this on Noble I see the following:

± ./run-pylint
= pylint =
Checking ./reviewtools/__init__.py
pylint: Command line or configuration file:1: UserWarning: 'Exception' is not a proper value for the 'overgeneral-exceptions' option. Use fully qualified name (maybe 'builtins.Exception' ?) instead. This will cease to be checked at runtime when the configuration upgrader is released.
....

Do you know if it would be backwards compatible to change this to:

diff --git a/pylintrc b/pylintrc
index 1ccf6e17e5..2ea3aa0ec3 100644
--- a/pylintrc
+++ b/pylintrc
@@ -87,4 +87,4 @@ valid-metaclass-classmethod-first-arg=mcs
 # Exceptions that will emit a warning when being caught. Defaults to
 # "BaseException, Exception".
 #overgeneral-exceptions=BaseException, Exception
-overgeneral-exceptions=Exception
\ No newline at end of file
+overgeneral-exceptions=builtin.Exception

Revision history for this message
Jorge Sancho Larraz (jslarraz) wrote :

Hey Alex, It seems I didn't save the inline commentaries :(

You are right in newer releases pylint complain about it. I've just tested in focal and using `builtin.Exception` seems to work properly.

However, as stated in the (non-previously-saved) inline commentary, I would still prefer to remove this configuration option and fallback to its default `builtin.BaseException, builtin.Exception` if there is no specific reason to prevent the use of `builtin.BaseException`.

Thanks for the review!

Revision history for this message
Jorge Sancho Larraz (jslarraz) wrote :

Completely remove pylintrc

Revision history for this message
Alex Murray (alexmurray) wrote :

LGTM - this way the defaults always get used

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/pylintrc b/pylintrc
0deleted file mode 1006440deleted file mode 100644
index ebe6ffa..0000000
--- a/pylintrc
+++ /dev/null
@@ -1,425 +0,0 @@
1[MASTER]
2
3# A comma-separated list of package or module names from where C extensions may
4# be loaded. Extensions are loading into the active Python interpreter and may
5# run arbitrary code
6extension-pkg-whitelist=
7
8# Add files or directories to the blacklist. They should be base names, not
9# paths.
10ignore=CVS
11
12# Add files or directories matching the regex patterns to the blacklist. The
13# regex matches against base names, not paths.
14ignore-patterns=
15
16# Python code to execute, usually for sys.path manipulation such as
17# pygtk.require().
18#init-hook=
19
20# Use multiple processes to speed up Pylint.
21jobs=1
22
23# List of plugins (as comma separated values of python modules names) to load,
24# usually to register additional checkers.
25load-plugins=
26
27# Pickle collected data for later comparisons.
28persistent=yes
29
30# Specify a configuration file.
31#rcfile=
32
33# Allow loading of arbitrary C extensions. Extensions are imported into the
34# active Python interpreter and may run arbitrary code.
35unsafe-load-any-extension=no
36
37
38[MESSAGES CONTROL]
39
40# Only show warnings with the listed confidence levels. Leave empty to show
41# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
42confidence=
43
44# Disable the message, report, category or checker with the given id(s). You
45# can either give multiple identifiers separated by comma (,) or put this
46# option multiple times (only on the command line, not in the configuration
47# file where it should appear only once).You can also use "--disable=all" to
48# disable everything first and then reenable specific checks. For example, if
49# you want to run only the similarities checker, you can use "--disable=all
50# --enable=similarities". If you want to run only the classes checker, but have
51# no Warning level messages displayed, use"--disable=all --enable=classes
52# --disable=W"
53disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
54
55# Enable the message, report, category or checker with the given id(s). You can
56# either give multiple identifier separated by comma (,) or put this option
57# multiple time (only on the command line, not in the configuration file where
58# it should appear only once). See also the "--disable" option for examples.
59enable=
60
61
62[REPORTS]
63
64# Python expression which should return a note less than 10 (10 is the highest
65# note). You have access to the variables errors warning, statement which
66# respectively contain the number of errors / warnings messages and the total
67# number of statements analyzed. This is used by the global evaluation report
68# (RP0004).
69evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
70
71# Template used to display messages. This is a python new-style format string
72# used to format the message information. See doc for all details
73#msg-template=
74
75# Set the output format. Available formats are text, parseable, colorized, json
76# and msvs (visual studio).You can also give a reporter class, eg
77# mypackage.mymodule.MyReporterClass.
78output-format=text
79
80# Tells whether to display a full report or only the messages
81reports=no
82
83# Activate the evaluation score.
84score=yes
85
86
87[REFACTORING]
88
89# Maximum number of nested blocks for function / method body
90max-nested-blocks=5
91
92
93[TYPECHECK]
94
95# List of decorators that produce context managers, such as
96# contextlib.contextmanager. Add to this list to register other decorators that
97# produce valid context managers.
98contextmanager-decorators=contextlib.contextmanager
99
100# List of members which are set dynamically and missed by pylint inference
101# system, and so shouldn't trigger E1101 when accessed. Python regular
102# expressions are accepted.
103generated-members=
104
105# Tells whether missing members accessed in mixin class should be ignored. A
106# mixin class is detected if its name ends with "mixin" (case insensitive).
107ignore-mixin-members=yes
108
109# This flag controls whether pylint should warn about no-member and similar
110# checks whenever an opaque object is returned when inferring. The inference
111# can return multiple potential results while evaluating a Python object, but
112# some branches might not be evaluated, which results in partial inference. In
113# that case, it might be useful to still emit no-member and other checks for
114# the rest of the inferred objects.
115ignore-on-opaque-inference=yes
116
117# List of class names for which member attributes should not be checked (useful
118# for classes with dynamically set attributes). This supports the use of
119# qualified names.
120ignored-classes=optparse.Values,thread._local,_thread._local
121
122# List of module names for which member attributes should not be checked
123# (useful for modules/projects where namespaces are manipulated during runtime
124# and thus existing member attributes cannot be deduced by static analysis. It
125# supports qualified module names, as well as Unix pattern matching.
126ignored-modules=
127
128# Show a hint with possible names when a member name was not found. The aspect
129# of finding the hint is based on edit distance.
130missing-member-hint=yes
131
132# The minimum edit distance a name should have in order to be considered a
133# similar match for a missing member name.
134missing-member-hint-distance=1
135
136# The total number of similar names that should be taken in consideration when
137# showing a hint for a missing member.
138missing-member-max-choices=1
139
140
141[SIMILARITIES]
142
143# Ignore comments when computing similarities.
144ignore-comments=yes
145
146# Ignore docstrings when computing similarities.
147ignore-docstrings=yes
148
149# Ignore imports when computing similarities.
150ignore-imports=no
151
152# Minimum lines number of a similarity.
153min-similarity-lines=4
154
155
156[VARIABLES]
157
158# List of additional names supposed to be defined in builtins. Remember that
159# you should avoid to define new builtins when possible.
160additional-builtins=
161
162# Tells whether unused global variables should be treated as a violation.
163allow-global-unused-variables=yes
164
165# List of strings which can identify a callback function by name. A callback
166# name must start or end with one of those strings.
167callbacks=cb_,_cb
168
169# A regular expression matching the name of dummy variables (i.e. expectedly
170# not used).
171dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
172
173# Argument names that match this expression will be ignored. Default to name
174# with leading underscore
175ignored-argument-names=_.*|^ignored_|^unused_
176
177# Tells whether we should check for unused import in __init__ files.
178init-import=no
179
180# List of qualified module names which can have objects that can redefine
181# builtins.
182redefining-builtins-modules=six.moves,future.builtins
183
184
185[FORMAT]
186
187# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
188expected-line-ending-format=
189
190# Regexp for a line that is allowed to be longer than the limit.
191ignore-long-lines=^\s*(# )?<?https?://\S+>?$
192
193# Number of spaces of indent required inside a hanging or continued line.
194indent-after-paren=4
195
196# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
197# tab).
198indent-string=' '
199
200# Maximum number of characters on a single line.
201max-line-length=100
202
203# Maximum number of lines in a module
204max-module-lines=1000
205
206# List of optional constructs for which whitespace checking is disabled. `dict-
207# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
208# `trailing-comma` allows a space between comma and closing bracket: (a, ).
209# `empty-line` allows space-only lines.
210no-space-check=trailing-comma,dict-separator
211
212# Allow the body of a class to be on the same line as the declaration if body
213# contains single statement.
214single-line-class-stmt=no
215
216# Allow the body of an if to be on the same line as the test if there is no
217# else.
218single-line-if-stmt=no
219
220
221[BASIC]
222
223# Naming hint for argument names
224argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
225
226# Regular expression matching correct argument names
227argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
228
229# Naming hint for attribute names
230attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
231
232# Regular expression matching correct attribute names
233attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
234
235# Bad variable names which should always be refused, separated by a comma
236bad-names=foo,bar,baz,toto,tutu,tata
237
238# Naming hint for class attribute names
239class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
240
241# Regular expression matching correct class attribute names
242class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
243
244# Naming hint for class names
245class-name-hint=[A-Z_][a-zA-Z0-9]+$
246
247# Regular expression matching correct class names
248class-rgx=[A-Z_][a-zA-Z0-9]+$
249
250# Naming hint for constant names
251const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
252
253# Regular expression matching correct constant names
254const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
255
256# Minimum line length for functions/classes that require docstrings, shorter
257# ones are exempt.
258docstring-min-length=-1
259
260# Naming hint for function names
261function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
262
263# Regular expression matching correct function names
264function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
265
266# Good variable names which should always be accepted, separated by a comma
267good-names=i,j,k,ex,Run,_
268
269# Include a hint for the correct naming format with invalid-name
270include-naming-hint=no
271
272# Naming hint for inline iteration names
273inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
274
275# Regular expression matching correct inline iteration names
276inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
277
278# Naming hint for method names
279method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
280
281# Regular expression matching correct method names
282method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
283
284# Naming hint for module names
285module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
286
287# Regular expression matching correct module names
288module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
289
290# Colon-delimited sets of names that determine each other's naming style when
291# the name regexes allow several styles.
292name-group=
293
294# Regular expression which should only match function or class names that do
295# not require a docstring.
296no-docstring-rgx=^_
297
298# List of decorators that produce properties, such as abc.abstractproperty. Add
299# to this list to register other decorators that produce valid properties.
300property-classes=abc.abstractproperty
301
302# Naming hint for variable names
303variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
304
305# Regular expression matching correct variable names
306variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
307
308
309[MISCELLANEOUS]
310
311# List of note tags to take in consideration, separated by a comma.
312notes=FIXME,XXX,TODO
313
314
315[SPELLING]
316
317# Spelling dictionary name. Available dictionaries: none. To make it working
318# install python-enchant package.
319spelling-dict=
320
321# List of comma separated words that should not be checked.
322spelling-ignore-words=
323
324# A path to a file that contains private dictionary; one word per line.
325spelling-private-dict-file=
326
327# Tells whether to store unknown words to indicated private dictionary in
328# --spelling-private-dict-file option instead of raising a message.
329spelling-store-unknown-words=no
330
331
332[LOGGING]
333
334# Logging modules to check that the string format arguments are in logging
335# function parameter format
336logging-modules=logging
337
338
339[CLASSES]
340
341# List of method names used to declare (i.e. assign) instance attributes.
342defining-attr-methods=__init__,__new__,setUp
343
344# List of member names, which should be excluded from the protected access
345# warning.
346exclude-protected=_asdict,_fields,_replace,_source,_make
347
348# List of valid names for the first argument in a class method.
349valid-classmethod-first-arg=cls
350
351# List of valid names for the first argument in a metaclass class method.
352valid-metaclass-classmethod-first-arg=mcs
353
354
355[IMPORTS]
356
357# Allow wildcard imports from modules that define __all__.
358allow-wildcard-with-all=no
359
360# Analyse import fallback blocks. This can be used to support both Python 2 and
361# 3 compatible code, which means that the block might have code that exists
362# only in one or another interpreter, leading to false positives when analysed.
363analyse-fallback-blocks=no
364
365# Deprecated modules which should not be used, separated by a comma
366deprecated-modules=optparse,tkinter.tix
367
368# Create a graph of external dependencies in the given file (report RP0402 must
369# not be disabled)
370ext-import-graph=
371
372# Create a graph of every (i.e. internal and external) dependencies in the
373# given file (report RP0402 must not be disabled)
374import-graph=
375
376# Create a graph of internal dependencies in the given file (report RP0402 must
377# not be disabled)
378int-import-graph=
379
380# Force import order to recognize a module as part of the standard
381# compatibility libraries.
382known-standard-library=
383
384# Force import order to recognize a module as part of a third party library.
385known-third-party=enchant
386
387
388[DESIGN]
389
390# Maximum number of arguments for function / method
391max-args=5
392
393# Maximum number of attributes for a class (see R0902).
394max-attributes=7
395
396# Maximum number of boolean expressions in a if statement
397max-bool-expr=5
398
399# Maximum number of branch for function / method body
400max-branches=12
401
402# Maximum number of locals for function / method body
403max-locals=15
404
405# Maximum number of parents for a class (see R0901).
406max-parents=7
407
408# Maximum number of public methods for a class (see R0904).
409max-public-methods=20
410
411# Maximum number of return / yield for function / method body
412max-returns=6
413
414# Maximum number of statements in function / method body
415max-statements=50
416
417# Minimum number of public methods for a class (see R0903).
418min-public-methods=2
419
420
421[EXCEPTIONS]
422
423# Exceptions that will emit a warning when being caught. Defaults to
424# "Exception"
425overgeneral-exceptions=Exception

Subscribers

People subscribed via source and target branches