From beaf102be3359976de9382e89e82193674382514 Mon Sep 17 00:00:00 2001 From: Frank Hoffmann <15r10nk-git@polarbit.de> Date: Sat, 31 Aug 2024 07:46:13 +0200 Subject: [PATCH] test: optimized test preformance by moving deadcode check to the end --- tests/test_main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 8309a71..5d4f83b 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -925,11 +925,10 @@ def check_filename(self, filename, check_names): if is_literal(node): continue - if len(values) == 0 and is_deadcode(node): - continue if isinstance(node,ast.Name) and node.id=="__debug__": continue + else: # x (is/is not) None none_comparison = ( @@ -1008,8 +1007,6 @@ def check_filename(self, filename, check_names): # "%50s"%(a,) is missing an BUILD_STRING instruction which normally maps to BinOp continue - if len(values)==0 and is_deadcode(node): - continue if ( isinstance(node, ast.Name) @@ -1018,6 +1015,7 @@ def check_filename(self, filename, check_names): ): continue + if sys.version_info >= (3, 12): if ( isinstance(node, ast.Call) @@ -1051,6 +1049,11 @@ def check_filename(self, filename, check_names): # `not not x` is optimized to a single TO_BOOL continue + + # the deadcode check has to be the last check because it is expensive + if len(values)==0 and is_deadcode(node): + continue + if sys.version_info >= (3, 10): correct = len(values) >= 1 elif sys.version_info >= (3, 9) and in_finally(node):