Skip to content

Commit edbabfe

Browse files
committed
[lint] add new version of .pylintrc and fix issues reported by pylint
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
1 parent d746df9 commit edbabfe

File tree

9 files changed

+34
-80
lines changed

9 files changed

+34
-80
lines changed

.pylintrc

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# -*- coding: utf-8; mode: conf -*-
2-
# lint Python modules using external checkers.
3-
#
4-
# This is the main checker controlling the other ones and the reports
5-
# generation. It is itself both a raw checker and an astng checker in order
6-
# to:
7-
# * handle message activation / deactivation at the module level
8-
# * handle some basic but necessary stats'data (number of classes, methods...)
9-
#
2+
103
[MASTER]
114

125
# A comma-separated list of package or module names from where C extensions may
@@ -59,7 +52,13 @@ confidence=
5952
# --enable=similarities". If you want to run only the classes checker, but have
6053
# no Warning level messages displayed, use"--disable=all --enable=classes
6154
# --disable=W"
62-
disable=bad-whitespace, duplicate-code
55+
disable=duplicate-code,
56+
missing-function-docstring,
57+
consider-using-f-string,
58+
use-dict-literal,
59+
unnecessary-lambda-assignment,
60+
redundant-u-string-prefix,
61+
consider-iterating-dictionary
6362

6463
# Enable the message, report, category or checker with the given id(s). You can
6564
# either give multiple identifier separated by comma (,) or put this option
@@ -105,39 +104,21 @@ max-nested-blocks=5
105104

106105
[BASIC]
107106

108-
# List of builtins function names that should not be used, separated by a comma
109-
bad-functions=map,filter,apply,input
110-
111-
# Naming hint for argument names
112-
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
113-
114107
# Regular expression matching correct argument names
115108
argument-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$
116109

117-
# Naming hint for attribute names
118-
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
119-
120110
# Regular expression matching correct attribute names
121111
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*)|([A-Z0-9_]*))$
122112

123113
# Bad variable names which should always be refused, separated by a comma
124114
bad-names=foo,bar,baz,toto,tutu,tata
125115

126-
# Naming hint for class attribute names
127-
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
128-
129116
# Regular expression matching correct class attribute names
130117
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
131118

132-
# Naming hint for class names
133-
class-name-hint=[A-Z_][a-zA-Z0-9]+$
134-
135119
# Regular expression matching correct class names
136120
class-rgx=[A-Z_][a-zA-Z0-9]+$
137121

138-
# Naming hint for constant names
139-
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
140-
141122
# Regular expression matching correct constant names
142123
const-rgx=(([a-zA-Z_][a-zA-Z0-9_]*)|(__.*__))$
143124
#const-rgx=[f]?[A-Z_][a-zA-Z0-9_]{2,30}$
@@ -146,9 +127,6 @@ const-rgx=(([a-zA-Z_][a-zA-Z0-9_]*)|(__.*__))$
146127
# ones are exempt.
147128
docstring-min-length=-1
148129

149-
# Naming hint for function names
150-
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
151-
152130
# Regular expression matching correct function names
153131
function-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$
154132

@@ -158,21 +136,12 @@ good-names=i,j,k,ex,Run,_,log,cfg,id
158136
# Include a hint for the correct naming format with invalid-name
159137
include-naming-hint=no
160138

161-
# Naming hint for inline iteration names
162-
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
163-
164139
# Regular expression matching correct inline iteration names
165140
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
166141

167-
# Naming hint for method names
168-
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
169-
170142
# Regular expression matching correct method names
171143
method-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*))$
172144

173-
# Naming hint for module names
174-
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
175-
176145
# Regular expression matching correct module names
177146
#module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
178147
module-rgx=([a-z_][a-z0-9_]*)$
@@ -189,9 +158,6 @@ no-docstring-rgx=^_
189158
# to this list to register other decorators that produce valid properties.
190159
property-classes=abc.abstractproperty
191160

192-
# Naming hint for variable names
193-
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
194-
195161
# Regular expression matching correct variable names
196162
variable-rgx=(([a-z][a-zA-Z0-9_]{2,30})|(_[a-z0-9_]*)|([a-z]))$
197163

@@ -217,12 +183,6 @@ max-line-length=120
217183
# Maximum number of lines in a module
218184
max-module-lines=2000
219185

220-
# List of optional constructs for which whitespace checking is disabled. `dict-
221-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
222-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
223-
# `empty-line` allows space-only lines.
224-
no-space-check=trailing-comma,dict-separator
225-
226186
# Allow the body of a class to be on the same line as the declaration if body
227187
# contains single statement.No config file found, using default configuration
228188

@@ -243,7 +203,7 @@ logging-modules=logging
243203
[MISCELLANEOUS]
244204

245205
# List of note tags to take in consideration, separated by a comma.
246-
notes=FIXME,XXX,TODO
206+
notes=FIXME,XXX
247207

248208

249209
[SIMILARITIES]
@@ -441,4 +401,4 @@ known-third-party=enchant
441401

442402
# Exceptions that will emit a warning when being caught. Defaults to
443403
# "Exception"
444-
overgeneral-exceptions=Exception
404+
overgeneral-exceptions=builtins.Exception

linuxdoc/autodoc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def main():
131131
CMD.rst_files = []
132132

133133
if CMD.threads > 1:
134+
# pylint: disable=consider-using-with
134135
pool = multiprocessing.Pool(CMD.threads)
135136
pool.map(autodoc_file, gather_filenames(CMD))
136137
pool.close()

linuxdoc/cdomainv2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ def handle_signature(self, sig, signode):
8888
if self.objtype == 'function':
8989
fullname = self.options["name"]
9090
else:
91-
# FIXME: handle :name: value of other declaration types?
91+
# ToDo: handle :name: value of other declaration types?
9292
pass
9393
return fullname
9494

95-
def add_target_and_index(self, name, sig, signode): # pylint: disable=arguments-differ
95+
def add_target_and_index(self, name, sig, signode): # pylint: disable=arguments-renamed
9696
# for C API items we add a prefix since names are usually not qualified
9797
# by a module name and so easily clash with e.g. section titles
9898
targetname = 'c.' + name

linuxdoc/kernel_doc.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ def map_row(row, map_table):
275275
return row
276276

277277
def highlight_parser(text, map_table):
278-
# FIXME: document this
279278
block_indent = 0
280279
row_indent = 0
281280
state = 'highlight' # [highlight|literal]
@@ -611,11 +610,11 @@ def setParser(self, parser):
611610
def setOptions(self, options):
612611
self.options = options
613612

614-
def highlight(self, cont):
613+
def highlight(self, text):
615614
u"""returns *highlighted* text"""
616615
if self.options.highlight:
617-
return highlight_parser(cont, self.HIGHLIGHT_MAP)
618-
return cont
616+
return highlight_parser(text, self.HIGHLIGHT_MAP)
617+
return text
619618

620619
def get_preamble(self):
621620
retVal = ""
@@ -2120,9 +2119,9 @@ def state_2(self, line):
21202119
else:
21212120
if ( self.options.markup == "reST"
21222121
and self.ctx.section.startswith("@")):
2123-
# FIXME: I doubt if it is a good idea to strip leading
2124-
# whitespaces in parameter description, but *over all* we
2125-
# get better reST output.
2122+
# I doubt if it is a good idea to strip leading whitespaces
2123+
# in parameter description, but *over all* we get better
2124+
# reST output.
21262125
cont_line = cont_line.strip()
21272126
# Sub-sections in parameter descriptions are not provided,
21282127
# but if this is a "lorem:\n" line create a new paragraph.
@@ -2428,15 +2427,6 @@ def dump_section(self, name, cont):
24282427
self.debug("dump_section(): %(name)s", name = name)
24292428
name = name.strip()
24302429
cont = cont.rstrip() # dismiss trailing whitespace
2431-
# FIXME: sections with '%CONST' prefix no longer exists
2432-
# _type_constant = RE(r"\%([-_\w]+)")
2433-
#if _type_constant.match(name): # '%CONST' - name of a constant.
2434-
# name = _type_constant[0]
2435-
# self.debug("constant section '%(name)s'", name = name)
2436-
# if self.ctx.constants.get(name, None):
2437-
# self.error("duplicate constant definition '%(name)s'"
2438-
# , name = name)
2439-
# self.ctx.constants[name] = cont
24402430

24412431
_type_param = RE(r"\@(\w[.\w]*)") # match @foo and @foo.bar
24422432
if _type_param.match(name): # '@parameter' - name of a parameter

linuxdoc/kernel_include.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def _run(self): # pylint: disable=R
9090
include_file = io.FileInput(source_path=path,
9191
encoding=encoding,
9292
error_handler=e_handler)
93-
except UnicodeEncodeError as error:
93+
except UnicodeEncodeError:
94+
# pylint: disable=raise-missing-from
9495
raise self.severe('Problems with "%s" directive path:\n'
9596
'Cannot encode input file path "%s" '
9697
'(wrong locale?).' %

linuxdoc/kfigure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def mkdir(folder, mode=0o775):
4848
os.makedirs(folder, mode)
4949

5050
def file2literal(fname):
51-
with open(fname, "r") as src:
51+
with open(fname, "r", encoding="utf-8") as src:
5252
data = src.read()
5353
node = nodes.literal_block(data, data)
5454
return node
@@ -255,7 +255,7 @@ def dot2format(app, dot_fname, out_fname): # pylint: disable=unused-argument
255255
cmd = [dot_cmd, '-T%s' % out_format, dot_fname]
256256
exit_code = 42
257257

258-
with open(out_fname, "w") as out:
258+
with open(out_fname, "w", encoding="utf-8") as out:
259259
exit_code = subprocess.call(cmd, stdout = out)
260260
if exit_code != 0:
261261
# pylint: disable=deprecated-method
@@ -391,7 +391,7 @@ def visit_kernel_render(self, node):
391391

392392
if not path.isfile(tmp_fname):
393393
mkdir(path.dirname(tmp_fname))
394-
with open(tmp_fname, "w") as out:
394+
with open(tmp_fname, "w", encoding="utf-8") as out:
395395
out.write(code)
396396

397397
img_node = nodes.image(node.rawsource, **node.attributes)

linuxdoc/manKernelDoc.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class KernelDocManBuilder(ManualPageBuilder):
290290
def init(self):
291291
pass
292292

293-
def is_manpage(self, node): # pylint: disable=no-self-use
293+
def is_manpage(self, node):
294294
if isinstance(node, nodes.section):
295295
return bool(
296296
Section2Manpage.sec2man_get_first_child(
@@ -305,7 +305,7 @@ def write_doc(self, docname, doctree):
305305
"""Where you actually write something to the filesystem."""
306306
pass
307307

308-
def get_partial_document(self, children): # pylint: disable=no-self-use
308+
def get_partial_document(self, children):
309309
doc_tree = new_document('<output>')
310310
doc_tree += children
311311
return doc_tree
@@ -323,8 +323,10 @@ def write(self, *ignored):
323323
logger.info(darkgreen("}"))
324324
man_nodes = master_tree.traverse(condition=self.is_manpage)
325325
if not man_nodes and not self.config.man_pages:
326-
logger.warn('no "man_pages" config value nor manual section found; no manual pages '
327-
'will be written')
326+
logger.warning(
327+
'no "man_pages" config value nor manual section found; no manual pages '
328+
'will be written'
329+
)
328330
return
329331

330332
logger.info(bold('START writing man pages ... '), nonl=True)

linuxdoc/rstFlatTable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def buildTableNode(self):
172172
tbody += self.buildTableRowNode(row)
173173
return table
174174

175-
def buildTableRowNode(self, row_data, classes=None): # pylint: disable=no-self-use
175+
def buildTableRowNode(self, row_data, classes=None):
176176
classes = [] if classes is None else classes
177177
row = nodes.row()
178178
for cell in row_data:
@@ -332,7 +332,7 @@ def parseRowItem(self, rowItem, rowNum):
332332
row.append( (cspan, rspan, cellElements) )
333333
return row
334334

335-
def parseCellItem(self, cellItem): # pylint: disable=no-self-use
335+
def parseCellItem(self, cellItem):
336336
# search and remove cspan, rspan colspec from the first element in
337337
# this listItem (field).
338338
cspan = rspan = 0

linuxdoc/rstKernelDoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def parseSource(self, opts):
340340

341341
def run(self):
342342

343-
# FIXME: think about again; these members has been added for convenience
343+
# ToDo: think about again; these members has been added for convenience
344344
self.parser = None # pylint: disable=attribute-defined-outside-init
345345
self.doc = self.state.document # pylint: disable=attribute-defined-outside-init
346346
self.env = self.doc.settings.env # pylint: disable=attribute-defined-outside-init
@@ -362,7 +362,7 @@ def run(self):
362362
if not self.doc.settings.file_insertion_enabled:
363363
raise FaultyOption('docutils: file insertion disabled')
364364
opts = self.getParserOptions()
365-
# FIXME: think about again; these members has been added for convenience
365+
# ToDo: think about again; these members has been added for convenience
366366
self.parser = self.parseSource(opts) # pylint: disable=attribute-defined-outside-init
367367
self.nodes.extend(self.getNodes())
368368

0 commit comments

Comments
 (0)