From da3096bc9998e7609b9191fdacc7ac0f46aedef0 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 30 Jul 2024 18:28:04 -0400 Subject: [PATCH] PROTON-2844: [Python] use more idiomatic type test This gets rid of a warning from recent python linter. --- python/tests/proton_tests/main.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/python/tests/proton_tests/main.py b/python/tests/proton_tests/main.py index f2d518fb3..69d9f4966 100644 --- a/python/tests/proton_tests/main.py +++ b/python/tests/proton_tests/main.py @@ -33,11 +33,6 @@ from .common import SkipTest -if sys.version_info[0] == 3: - CLASS_TYPES = (type,) -else: - CLASS_TYPES = (type, types.ClassType) - levels = { "DEBUG": DEBUG, "INFO": INFO, @@ -581,12 +576,11 @@ def matches(self, name): class FunctionScanner(PatternMatcher): def inspect(self, obj): - return type(obj) is types.FunctionType and self.matches(obj.__name__) + return isinstance(obj, types.FunctionType) and self.matches(obj.__name__) def descend(self, func): - # the None is required for older versions of python return - yield None + yield def extract(self, func): yield FunctionTest(func) @@ -595,12 +589,11 @@ def extract(self, func): class ClassScanner(PatternMatcher): def inspect(self, obj): - return type(obj) in CLASS_TYPES and self.matches(obj.__name__) + return isinstance(obj, type) and self.matches(obj.__name__) def descend(self, cls): - # the None is required for older versions of python return - yield None + yield def extract(self, cls): for name in sorted(dir(cls)): @@ -612,16 +605,15 @@ def extract(self, cls): class ModuleScanner: def inspect(self, obj): - return type(obj) is types.ModuleType + return isinstance(obj, types.ModuleType) def descend(self, obj): for name in sorted(dir(obj)): yield getattr(obj, name) def extract(self, obj): - # the None is required for older versions of python return - yield None + yield class Harness: