From 6a5d2545c6de9db64d6dc98882008666ea6056e8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 24 Jul 2019 12:08:59 -0400 Subject: [PATCH] src: use ==/!= to compare str, bytes, and int literals Add a more flake8 tests * F63 tests are usually about the confusion between identity and equality in Python. * F7 tests logic errors and syntax errors in type hints --- gyp/input.py | 2 +- setup.cfg | 2 +- test/linux/ldflags-duplicates/check-ldflags.py | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gyp/input.py b/gyp/input.py index 81246a6b..4b0023e7 100644 --- a/gyp/input.py +++ b/gyp/input.py @@ -958,7 +958,7 @@ def LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key): if variable_name in variables: # If the variable is already set, don't set it. continue - if the_dict_key is 'variables' and variable_name in the_dict: + if the_dict_key == 'variables' and variable_name in the_dict: # If the variable is set without a % in the_dict, and the_dict is a # variables dict (making |variables| a varaibles sub-dict of a # variables dict), use the_dict's definition. diff --git a/setup.cfg b/setup.cfg index 20b3ca7f..51f19203 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,4 +11,4 @@ entry_points = {'console_scripts': ['gyp=gyp:script_main']} [flake8] exclude = .venv,out,testlib/SConsLib -select = E9,F8 +select = E9,F63,F7,F8 diff --git a/test/linux/ldflags-duplicates/check-ldflags.py b/test/linux/ldflags-duplicates/check-ldflags.py index ef102952..acdefc29 100755 --- a/test/linux/ldflags-duplicates/check-ldflags.py +++ b/test/linux/ldflags-duplicates/check-ldflags.py @@ -13,16 +13,16 @@ import sys def CheckContainsFlags(args, substring): - if args.find(substring) is -1: + found = substring in args + if not found: print('ERROR: Linker arguments "%s" are missing in "%s"' % (substring, args)) - return False; - return True; + return found if __name__ == '__main__': args = " ".join(sys.argv) - print("args = " +args) - if not CheckContainsFlags(args, 'lib1.a -Wl,--no-whole-archive') \ - or not CheckContainsFlags(args, 'lib2.a -Wl,--no-whole-archive'): - sys.exit(1); + print("args = " + args) + if (not CheckContainsFlags(args, 'lib1.a -Wl,--no-whole-archive') + or not CheckContainsFlags(args, 'lib2.a -Wl,--no-whole-archive')): + sys.exit(1) sys.exit(0)