Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static checker #3734

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ requirements: pip
- $(PYTHON) -m pip install -r requirements.txt

check:
inspekt checkall --disable-lint W,R,C,E0203,E0601,E1002,E1101,E1102,E1103,E1120,F0401,I0011,E1003,W605 --disable-style W605,W606,E501,E265,W601,E402,E722,E741 --exclude avocado-libs,scripts/github --no-license-check
inspekt checkall --disable-lint W,R,C,E0203,E0601,E1002,E1101,E1102,E1103,E1120,F0401,I0011,E1003,W605,I1101 --disable-style W605,W606,E501,E265,W601,E402,E722,E741 --exclude avocado-libs,scripts/github --no-license-check
pylint --errors-only --disable=all --enable=spelling --spelling-dict=en_US --spelling-private-dict-file=spell.ignore *

clean:
Expand Down
2 changes: 1 addition & 1 deletion scripts/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def getTtestPvalue(self, fs_dict1, fs_dict2, paired=None, ratio=None):

for line in range(len(s1)):
tmp = []
if type(s1[line]) != list:
if not isinstance(s1[line], list):
tmp = s1[line]
else:
if len(s1[line][0]) < 2:
Expand Down
26 changes: 13 additions & 13 deletions virttest/cartesian_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,19 +1275,19 @@ def get_until_no_white(self, end_tokens=None):
"""
if end_tokens is None:
end_tokens = [LEndL]
return [x for x in self.get_until_gen(end_tokens) if type(x) != LWhite]
return [x for x in self.get_until_gen(end_tokens) if not isinstance(x, LWhite)]

def rest_line_gen(self):
token = next(self.generator)
while type(token) != LEndL:
while not isinstance(token, LEndL):
yield token
token = next(self.generator)

def rest_line(self):
return [x for x in self.rest_line_gen()]

def rest_line_no_white(self):
return [x for x in self.rest_line_gen() if type(x) != LWhite]
return [x for x in self.rest_line_gen() if not isinstance(x, LWhite)]

def rest_line_as_LString(self):
self.rest_as_string = True
Expand All @@ -1307,7 +1307,7 @@ def get_next_check(self, lType):

def get_next_check_nw(self, lType):
token = next(self.generator)
while type(token) == LWhite:
while isinstance(token, LWhite):
token = next(self.generator)
if type(token) in lType:
return type(token), token
Expand All @@ -1329,7 +1329,7 @@ def check_token(self, token, lType):

def next_nw(gener):
token = next(gener)
while type(token) == LWhite:
while isinstance(token, LWhite):
token = next(gener)
return token

Expand Down Expand Up @@ -1410,7 +1410,7 @@ def parse_filter(lexer, tokens):
lexer.linenum)
dots = 1
token = next(tokens)
while type(token) == LWhite:
while isinstance(token, LWhite):
token = next(tokens)
typet, token = lexer.check_token(token, [LIdentifier,
LComa, LDot,
Expand Down Expand Up @@ -1590,7 +1590,7 @@ def _parse(self, lexer, node=None, prev_indent=-1):

op.set_operands(identifier, value)
d_nin_val = "$" not in value
if type(op) == LSet and d_nin_val: # Optimization
if isinstance(op, LSet) and d_nin_val: # Optimization
op.apply_to_dict(pre_dict)
else:
if pre_dict:
Expand All @@ -1610,7 +1610,7 @@ def _parse(self, lexer, node=None, prev_indent=-1):
op)]
lexer.get_next_check([LEndL])

elif type(identifier[-1]) == LColon: # condition:
elif isinstance(identifier[-1], LColon): # condition:
# Parse:
# xxx.yyy.(aaa=bbb):
identifier = [token] + identifier[:-1]
Expand Down Expand Up @@ -1678,13 +1678,13 @@ def _parse(self, lexer, node=None, prev_indent=-1):
else:
raw_name = [x for x in name[:-1]]
name = [x for x in name[:-1]
if type(x) == LIdentifier]
if isinstance(x, LIdentifier)]

token = next(lexer.generator)
while type(token) == LWhite:
while isinstance(token, LWhite):
token = next(lexer.generator)
tokens = None
if type(token) != LEndL:
if not isinstance(token, LEndL):
tokens = [token] + lexer.get_until([LEndL])
deps = parse_filter(lexer, tokens)
else:
Expand Down Expand Up @@ -1796,7 +1796,7 @@ def _parse(self, lexer, node=None, prev_indent=-1):
elif typet == LSet: # [xxx = yyyy]
tokens = lexer.get_until_no_white([LRBracket,
LEndL])
if type(tokens[-1]) == LRBracket:
if isinstance(tokens[-1], LRBracket):
if ident not in meta:
meta[ident] = []
meta[ident].append(tokens[:-1])
Expand All @@ -1812,7 +1812,7 @@ def _parse(self, lexer, node=None, prev_indent=-1):

if "default" in meta:
for wd in meta["default"]:
if type(wd) != list:
if not isinstance(wd, list):
raise ParserError("Syntax ERROR expected "
"[default=xxx]",
lexer.line,
Expand Down
2 changes: 1 addition & 1 deletion virttest/unittest_utils/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, value):
def _types_match(arg1, arg2):
if isinstance(arg1, basestring) and isinstance(arg2, basestring):
return True
return type(arg1) == type(arg2)
return type(arg1) is type(arg2)

@classmethod
def _compare(cls, actual_arg, expected_arg):
Expand Down
2 changes: 1 addition & 1 deletion virttest/utils_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def set_float(self, option, value):
self[option] = '%s' % float(value)

def set_boolean(self, option, value):
if type(value) == str:
if isinstance(value, str):
value = int(value)
if bool(value):
self[option] = '1'
Expand Down
4 changes: 2 additions & 2 deletions virttest/utils_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def _parse_result(result_str):

for key, value_str in _split_result_str(result_str):
value = _parse_result(value_str)
if type(result) == list:
if isinstance(result, list):
result.append((key, value))
elif type(result) == dict:
elif isinstance(result, dict):
result[key] = value

return result
Expand Down