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

Subscribers

People subscribed via source and target branches