mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-25 14:56:03 +00:00
patman: Correct pylint errors
Fix pylint errors that can be fixed and mask those that seem to be incorrect. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
f9a719e295
commit
32cc6ae273
11 changed files with 39 additions and 33 deletions
|
@ -77,4 +77,15 @@ If the pylint version is updated in CI, this may result in needing to regenerate
|
||||||
`scripts/pylint.base`.
|
`scripts/pylint.base`.
|
||||||
|
|
||||||
|
|
||||||
|
Checking for errors
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
If you only want to check for pylint errors, use::
|
||||||
|
|
||||||
|
PYTHONPATH=/path/to/scripts/dtc/pylibfdt/ make pylint_err
|
||||||
|
|
||||||
|
This will show only pylint errors. Note that you must set PYTHONPATH to point
|
||||||
|
to the pylibfdt directory build by U-Boot (typically the sandbox_spl board). If
|
||||||
|
you have used `make qcheck` then it sill be in `board-sandbox_spl`.
|
||||||
|
|
||||||
.. _`PEP 8`: https://www.python.org/dev/peps/pep-0008/
|
.. _`PEP 8`: https://www.python.org/dev/peps/pep-0008/
|
||||||
|
|
0
tools/concurrencytest/__init__.py
Normal file
0
tools/concurrencytest/__init__.py
Normal file
|
@ -125,7 +125,7 @@ def check_patch_parse(checkpatch_output, verbose=False):
|
||||||
Returns:
|
Returns:
|
||||||
namedtuple containing:
|
namedtuple containing:
|
||||||
ok: False=failure, True=ok
|
ok: False=failure, True=ok
|
||||||
problems: List of problems, each a dict:
|
problems (list of problems): each a dict:
|
||||||
'type'; error or warning
|
'type'; error or warning
|
||||||
'msg': text message
|
'msg': text message
|
||||||
'file' : filename
|
'file' : filename
|
||||||
|
@ -252,6 +252,8 @@ def check_patches(verbose, args):
|
||||||
if (len(result.problems) != result.errors + result.warnings +
|
if (len(result.problems) != result.errors + result.warnings +
|
||||||
result.checks):
|
result.checks):
|
||||||
print("Internal error: some problems lost")
|
print("Internal error: some problems lost")
|
||||||
|
# Python seems to get confused by this
|
||||||
|
# pylint: disable=E1133
|
||||||
for item in result.problems:
|
for item in result.problems:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
get_warning_msg(col, item.get('type', '<unknown>'),
|
get_warning_msg(col, item.get('type', '<unknown>'),
|
||||||
|
|
|
@ -17,13 +17,6 @@ class CommandResult:
|
||||||
return_code: Return code from command
|
return_code: Return code from command
|
||||||
exception: Exception received, or None if all ok
|
exception: Exception received, or None if all ok
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
|
||||||
self.stdout = None
|
|
||||||
self.stderr = None
|
|
||||||
self.combined = None
|
|
||||||
self.return_code = None
|
|
||||||
self.exception = None
|
|
||||||
|
|
||||||
def __init__(self, stdout='', stderr='', combined='', return_code=0,
|
def __init__(self, stdout='', stderr='', combined='', return_code=0,
|
||||||
exception=None):
|
exception=None):
|
||||||
self.stdout = stdout
|
self.stdout = stdout
|
||||||
|
@ -72,6 +65,7 @@ def run_pipe(pipe_list, infile=None, outfile=None,
|
||||||
"""
|
"""
|
||||||
if test_result:
|
if test_result:
|
||||||
if hasattr(test_result, '__call__'):
|
if hasattr(test_result, '__call__'):
|
||||||
|
# pylint: disable=E1102
|
||||||
result = test_result(pipe_list=pipe_list)
|
result = test_result(pipe_list=pipe_list)
|
||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Commit:
|
||||||
"""
|
"""
|
||||||
def __init__(self, hash):
|
def __init__(self, hash):
|
||||||
self.hash = hash
|
self.hash = hash
|
||||||
self.subject = None
|
self.subject = ''
|
||||||
self.tags = []
|
self.tags = []
|
||||||
self.changes = {}
|
self.changes = {}
|
||||||
self.cc_list = []
|
self.cc_list = []
|
||||||
|
|
|
@ -113,7 +113,7 @@ class Popen(subprocess.Popen):
|
||||||
return b''
|
return b''
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def communicate_filter(self, output):
|
def communicate_filter(self, output, input_buf=''):
|
||||||
"""Interact with process: Read data from stdout and stderr.
|
"""Interact with process: Read data from stdout and stderr.
|
||||||
|
|
||||||
This method runs until end-of-file is reached, then waits for the
|
This method runs until end-of-file is reached, then waits for the
|
||||||
|
@ -166,7 +166,7 @@ class Popen(subprocess.Popen):
|
||||||
# Flush stdio buffer. This might block, if the user has
|
# Flush stdio buffer. This might block, if the user has
|
||||||
# been writing to .stdin in an uncontrolled fashion.
|
# been writing to .stdin in an uncontrolled fashion.
|
||||||
self.stdin.flush()
|
self.stdin.flush()
|
||||||
if input:
|
if input_buf:
|
||||||
write_set.append(self.stdin)
|
write_set.append(self.stdin)
|
||||||
else:
|
else:
|
||||||
self.stdin.close()
|
self.stdin.close()
|
||||||
|
@ -195,10 +195,10 @@ class Popen(subprocess.Popen):
|
||||||
# When select has indicated that the file is writable,
|
# When select has indicated that the file is writable,
|
||||||
# we can write up to PIPE_BUF bytes without risk
|
# we can write up to PIPE_BUF bytes without risk
|
||||||
# blocking. POSIX defines PIPE_BUF >= 512
|
# blocking. POSIX defines PIPE_BUF >= 512
|
||||||
chunk = input[input_offset : input_offset + 512]
|
chunk = input_buf[input_offset : input_offset + 512]
|
||||||
bytes_written = os.write(self.stdin.fileno(), chunk)
|
bytes_written = os.write(self.stdin.fileno(), chunk)
|
||||||
input_offset += bytes_written
|
input_offset += bytes_written
|
||||||
if input_offset >= len(input):
|
if input_offset >= len(input_buf):
|
||||||
self.stdin.close()
|
self.stdin.close()
|
||||||
write_set.remove(self.stdin)
|
write_set.remove(self.stdin)
|
||||||
|
|
||||||
|
@ -240,16 +240,6 @@ class Popen(subprocess.Popen):
|
||||||
stderr = self.convert_data(stderr)
|
stderr = self.convert_data(stderr)
|
||||||
combined = self.convert_data(combined)
|
combined = self.convert_data(combined)
|
||||||
|
|
||||||
# Translate newlines, if requested. We cannot let the file
|
|
||||||
# object do the translation: It is based on stdio, which is
|
|
||||||
# impossible to combine with select (unless forcing no
|
|
||||||
# buffering).
|
|
||||||
if self.universal_newlines and hasattr(file, 'newlines'):
|
|
||||||
if stdout:
|
|
||||||
stdout = self._translate_newlines(stdout)
|
|
||||||
if stderr:
|
|
||||||
stderr = self._translate_newlines(stderr)
|
|
||||||
|
|
||||||
self.wait()
|
self.wait()
|
||||||
return (stdout, stderr, combined)
|
return (stdout, stderr, combined)
|
||||||
|
|
||||||
|
|
|
@ -341,6 +341,8 @@ Changes in v2:
|
||||||
tools.write_file(path, text, binary=False)
|
tools.write_file(path, text, binary=False)
|
||||||
index = self.repo.index
|
index = self.repo.index
|
||||||
index.add(fname)
|
index.add(fname)
|
||||||
|
# pylint doesn't seem to find this
|
||||||
|
# pylint: disable=E1101
|
||||||
author = pygit2.Signature('Test user', 'test@email.com')
|
author = pygit2.Signature('Test user', 'test@email.com')
|
||||||
committer = author
|
committer = author
|
||||||
tree = index.write_tree()
|
tree = index.write_tree()
|
||||||
|
@ -363,6 +365,8 @@ Changes in v2:
|
||||||
self.repo = repo
|
self.repo = repo
|
||||||
new_tree = repo.TreeBuilder().write()
|
new_tree = repo.TreeBuilder().write()
|
||||||
|
|
||||||
|
# pylint doesn't seem to find this
|
||||||
|
# pylint: disable=E1101
|
||||||
author = pygit2.Signature('Test user', 'test@email.com')
|
author = pygit2.Signature('Test user', 'test@email.com')
|
||||||
committer = author
|
committer = author
|
||||||
_ = repo.create_commit('HEAD', author, committer, 'Created master',
|
_ = repo.create_commit('HEAD', author, committer, 'Created master',
|
||||||
|
@ -414,6 +418,8 @@ better than before''')
|
||||||
first_target = repo.revparse_single('HEAD')
|
first_target = repo.revparse_single('HEAD')
|
||||||
|
|
||||||
target = repo.revparse_single('HEAD~2')
|
target = repo.revparse_single('HEAD~2')
|
||||||
|
# pylint doesn't seem to find this
|
||||||
|
# pylint: disable=E1101
|
||||||
repo.reset(target.oid, pygit2.GIT_CHECKOUT_FORCE)
|
repo.reset(target.oid, pygit2.GIT_CHECKOUT_FORCE)
|
||||||
self.make_commit_with_file('video: Some video improvements', '''
|
self.make_commit_with_file('video: Some video improvements', '''
|
||||||
Fix up the video so that
|
Fix up the video so that
|
||||||
|
@ -459,6 +465,8 @@ complicated as possible''')
|
||||||
"""Test creating patches from a branch"""
|
"""Test creating patches from a branch"""
|
||||||
repo = self.make_git_tree()
|
repo = self.make_git_tree()
|
||||||
target = repo.lookup_reference('refs/heads/first')
|
target = repo.lookup_reference('refs/heads/first')
|
||||||
|
# pylint doesn't seem to find this
|
||||||
|
# pylint: disable=E1101
|
||||||
self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
|
self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
|
||||||
control.setup()
|
control.setup()
|
||||||
try:
|
try:
|
||||||
|
@ -615,6 +623,8 @@ diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
|
||||||
"""Test CountCommitsToBranch when there is no upstream"""
|
"""Test CountCommitsToBranch when there is no upstream"""
|
||||||
repo = self.make_git_tree()
|
repo = self.make_git_tree()
|
||||||
target = repo.lookup_reference('refs/heads/base')
|
target = repo.lookup_reference('refs/heads/base')
|
||||||
|
# pylint doesn't seem to find this
|
||||||
|
# pylint: disable=E1101
|
||||||
self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
|
self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
|
||||||
|
|
||||||
# Check that it can detect the current branch
|
# Check that it can detect the current branch
|
||||||
|
|
|
@ -597,7 +597,7 @@ class PatchStream:
|
||||||
if 'prefix' in self.series:
|
if 'prefix' in self.series:
|
||||||
parts.append(self.series['prefix'])
|
parts.append(self.series['prefix'])
|
||||||
if 'postfix' in self.series:
|
if 'postfix' in self.series:
|
||||||
parts.append(self.serties['postfix'])
|
parts.append(self.series['postfix'])
|
||||||
if 'version' in self.series:
|
if 'version' in self.series:
|
||||||
parts.append("v%s" % self.series['version'])
|
parts.append("v%s" % self.series['version'])
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,7 @@ class Series(dict):
|
||||||
cc_list = list(self._generated_cc[commit.patch])
|
cc_list = list(self._generated_cc[commit.patch])
|
||||||
for email in sorted(set(cc_list) - to_set - cc_set):
|
for email in sorted(set(cc_list) - to_set - cc_set):
|
||||||
if email == None:
|
if email == None:
|
||||||
email = col.build(col.YELLOW, "<alias '%s' not found>"
|
email = col.build(col.YELLOW, '<alias not found>')
|
||||||
% tag)
|
|
||||||
if email:
|
if email:
|
||||||
print(' Cc: ', email)
|
print(' Cc: ', email)
|
||||||
print
|
print
|
||||||
|
|
|
@ -200,12 +200,12 @@ def CreatePatmanConfigFile(gitutil, config_fname):
|
||||||
"""
|
"""
|
||||||
name = gitutil.get_default_user_name()
|
name = gitutil.get_default_user_name()
|
||||||
if name == None:
|
if name == None:
|
||||||
name = raw_input("Enter name: ")
|
name = input("Enter name: ")
|
||||||
|
|
||||||
email = gitutil.get_default_user_email()
|
email = gitutil.get_default_user_email()
|
||||||
|
|
||||||
if email == None:
|
if email == None:
|
||||||
email = raw_input("Enter email: ")
|
email = input("Enter email: ")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open(config_fname, 'w')
|
f = open(config_fname, 'w')
|
||||||
|
|
|
@ -62,8 +62,8 @@ def prepare_output_dir(dirname, preserve=False):
|
||||||
try:
|
try:
|
||||||
os.makedirs(outdir)
|
os.makedirs(outdir)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
raise CmdError("Cannot make output directory '%s': '%s'" %
|
raise ValueError(
|
||||||
(outdir, err.strerror))
|
f"Cannot make output directory 'outdir': 'err.strerror'")
|
||||||
tout.debug("Using output directory '%s'" % outdir)
|
tout.debug("Using output directory '%s'" % outdir)
|
||||||
else:
|
else:
|
||||||
outdir = tempfile.mkdtemp(prefix='binman.')
|
outdir = tempfile.mkdtemp(prefix='binman.')
|
||||||
|
@ -160,7 +160,7 @@ def get_input_filename_glob(pattern):
|
||||||
A list of matching files in all input directories
|
A list of matching files in all input directories
|
||||||
"""
|
"""
|
||||||
if not indir:
|
if not indir:
|
||||||
return glob.glob(fname)
|
return glob.glob(pattern)
|
||||||
files = []
|
files = []
|
||||||
for dirname in indir:
|
for dirname in indir:
|
||||||
pathname = os.path.join(dirname, pattern)
|
pathname = os.path.join(dirname, pattern)
|
||||||
|
@ -201,7 +201,7 @@ def path_has_file(path_spec, fname):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_host_compile_tool(name):
|
def get_host_compile_tool(env, name):
|
||||||
"""Get the host-specific version for a compile tool
|
"""Get the host-specific version for a compile tool
|
||||||
|
|
||||||
This checks the environment variables that specify which version of
|
This checks the environment variables that specify which version of
|
||||||
|
@ -356,7 +356,7 @@ def run_result(name, *args, **kwargs):
|
||||||
name, extra_args = get_target_compile_tool(name)
|
name, extra_args = get_target_compile_tool(name)
|
||||||
args = tuple(extra_args) + args
|
args = tuple(extra_args) + args
|
||||||
elif for_host:
|
elif for_host:
|
||||||
name, extra_args = get_host_compile_tool(name)
|
name, extra_args = get_host_compile_tool(env, name)
|
||||||
args = tuple(extra_args) + args
|
args = tuple(extra_args) + args
|
||||||
name = os.path.expanduser(name) # Expand paths containing ~
|
name = os.path.expanduser(name) # Expand paths containing ~
|
||||||
all_args = (name,) + args
|
all_args = (name,) + args
|
||||||
|
|
Loading…
Add table
Reference in a new issue