Fix the simplest pylint warnings (variables/imports, semicolons, etc) and re-enable them in pylintrc

This commit is contained in:
Kamil Śliwak 2021-01-21 16:17:01 +01:00
parent 3fb42f60b4
commit b96de320e2
15 changed files with 27 additions and 41 deletions

View File

@ -413,7 +413,7 @@ def commandline_parser() -> ArgumentParser:
action='store_true',
help="Immediately exit and print compiler output if the compiler exits with an error.",
)
return parser;
return parser
if __name__ == "__main__":

View File

@ -39,7 +39,7 @@ def colorize(left, right, id):
reset = "\x1b[0m"
colors = [red, yellow]
color = colors[id % len(colors)]
function, arguments, results = parse_call(right)
function, _arguments, _results = parse_call(right)
left = left.replace("compileAndRun", color + "compileAndRun" + reset)
right = right.replace("constructor", color + "constructor" + reset)
if function:
@ -158,7 +158,7 @@ def main(argv):
interactive = False
input_file = None
try:
opts, args = getopt.getopt(argv, "if:")
opts, _args = getopt.getopt(argv, "if:")
except getopt.GetoptError:
print("./remove-testcases.py [-i] [-f <full path to SolidityEndToEndTest.cpp>]")
sys.exit(1)

View File

@ -158,7 +158,7 @@ class TraceAnalyser:
for trace_id, trace in enumerate(left.traces):
left_trace = trace
right_trace = right.traces[trace_id]
assert (left_trace.kind == right_trace.kind)
assert left_trace.kind == right_trace.kind
if str(left_trace) != str(right_trace):
mismatch_info = " " + str(left_trace) + "\n"
mismatch_info += " " + str(right_trace) + "\n"
@ -179,7 +179,7 @@ def main(argv):
extracted_tests_trace_file = None
end_to_end_trace_file = None
try:
opts, args = getopt.getopt(argv, "s:e:")
opts, _args = getopt.getopt(argv, "s:e:")
except getopt.GetoptError:
print("verify-testcases.py [-s <path to semantic-trace>] [-e <path to endToEndExtraction-trace>]")
sys.exit(2)

View File

@ -261,9 +261,9 @@ def main(argv):
no_confirm = False
examine_coverage = False
next_id = False
opts, args = getopt.getopt(argv, "", ["check", "fix", "no-confirm", "examine-coverage", "next"])
opts, _args = getopt.getopt(argv, "", ["check", "fix", "no-confirm", "examine-coverage", "next"])
for opt, arg in opts:
for opt, _arg in opts:
if opt == "--check":
check = True
elif opt == "--fix":

View File

@ -49,9 +49,10 @@ def readDependencies(fname):
if line[0] == '\t':
library = line.split(' ', 1)[0][1:]
if (library.startswith("/usr/local/lib") or
library.startswith("/usr/local/opt") or
library.startswith("/Users/")):
if (os.path.basename(library) != os.path.basename(fname)):
library.startswith("/usr/local/opt") or
library.startswith("/Users/")
):
if os.path.basename(library) != os.path.basename(fname):
command = "install_name_tool -change " + \
library + " @executable_path/./" + \
os.path.basename(library) + " " + fname

View File

@ -20,7 +20,7 @@ repository. The changes are compared against ``origin/develop``.
import subprocess
from pathlib import Path
from enum import Enum
from parsec import *
from parsec import generate, ParseError, regex, string
from tabulate import tabulate
class Kind(Enum):
@ -56,10 +56,10 @@ def diff_string() -> (Kind, Diff, int):
-// gas irOptimized: 138070
"""
diff_kind = yield (minus | plus)
diff_kind = yield minus | plus
yield comment
yield space
codegen_kind = yield (gas_ir_optimized ^ gas_legacy_optimized ^ gas_legacy)
codegen_kind = yield gas_ir_optimized ^ gas_legacy_optimized ^ gas_legacy
yield colon
yield space
val = yield number()

View File

@ -6,7 +6,6 @@
# into files for e.g. fuzz testing as
# scripts/isolate_tests.py test/libsolidity/*
import sys
import re
import os
import hashlib

View File

@ -9,7 +9,6 @@ from os import path, walk
from sys import exit
from textwrap import dedent
import subprocess
import sys
PROJECT_ROOT = path.dirname(path.dirname(path.realpath(__file__)))
PYLINT_RCFILE = f"{PROJECT_ROOT}/scripts/pylintrc"

View File

@ -24,24 +24,15 @@ disable=
duplicate-code,
invalid-name,
missing-docstring,
mixed-indentation,
no-else-return,
no-self-use,
pointless-string-statement,
redefined-builtin,
redefined-outer-name,
singleton-comparison,
superfluous-parens,
too-few-public-methods,
trailing-newlines,
undefined-variable,
ungrouped-imports,
unnecessary-semicolon,
unused-import,
unused-variable,
unused-wildcard-import,
useless-object-inheritance,
wildcard-import
too-many-public-methods,
ungrouped-imports
[BASIC]

View File

@ -11,7 +11,7 @@ import time
DESCRIPTION = """Regressor is a tool to run regression tests in a CI env."""
class PrintDotsThread(object):
class PrintDotsThread:
"""Prints a dot every "interval" (default is 300) seconds"""
def __init__(self, interval=300):
@ -30,7 +30,7 @@ class PrintDotsThread(object):
print(".")
time.sleep(self.interval)
class regressor():
class regressor:
_re_sanitizer_log = re.compile(r"""ERROR: (libFuzzer|UndefinedBehaviorSanitizer)""")
def __init__(self, description, args):

View File

@ -44,9 +44,7 @@ def writeSourceToFile(lines):
os.system("mkdir -p " + filePath)
with open(srcName, mode='a+', encoding='utf8', newline='') as f:
createdSources.append(srcName)
i = 0
for idx, line in enumerate(lines[1:]):
# write to file
if line[:12] != "==== Source:":
f.write(line)

View File

@ -25,12 +25,12 @@ BitWidth = BitVecVal(n_bits, n_bits)
rule.require(ULT(B, BitWidth))
# Non optimized result
nonopt_1 = SHR(B, AND(X, A));
nonopt_2 = SHR(B, AND(A, X));
nonopt_1 = SHR(B, AND(X, A))
nonopt_2 = SHR(B, AND(A, X))
# Optimized result
Mask = SHR(B, A);
opt = AND(SHR(B, X), Mask);
Mask = SHR(B, A)
opt = AND(SHR(B, X), Mask)
rule.check(nonopt_1, opt)
rule.check(nonopt_2, opt)

View File

@ -34,4 +34,3 @@ rule3.check(
SIGNEXTEND(A, SIGNEXTEND(B, X)),
SIGNEXTEND(If(ULT(A, B), A, B), X)
)

View File

@ -28,4 +28,3 @@ rule.check(
SIGNEXTEND(A, SHR(B, X)),
SAR(B, X)
)

View File

@ -1,27 +1,27 @@
from z3 import *
def BVUnsignedUpCast(x, n_bits):
assert(x.size() <= n_bits)
assert x.size() <= n_bits
if x.size() < n_bits:
return Concat(BitVecVal(0, n_bits - x.size()), x)
else:
return x
def BVUnsignedMax(type_bits, n_bits):
assert(type_bits <= n_bits)
assert type_bits <= n_bits
return BitVecVal((1 << type_bits) - 1, n_bits)
def BVSignedUpCast(x, n_bits):
assert(x.size() <= n_bits)
assert x.size() <= n_bits
if x.size() < n_bits:
return Concat(If(x < 0, BitVecVal(-1, n_bits - x.size()), BitVecVal(0, n_bits - x.size())), x)
else:
return x
def BVSignedMax(type_bits, n_bits):
assert(type_bits <= n_bits)
assert type_bits <= n_bits
return BitVecVal((1 << (type_bits - 1)) - 1, n_bits)
def BVSignedMin(type_bits, n_bits):
assert(type_bits <= n_bits)
assert type_bits <= n_bits
return BitVecVal(-(1 << (type_bits - 1)), n_bits)