This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit da3096bc9998e7609b9191fdacc7ac0f46aedef0
Author: Andrew Stitcher <[email protected]>
AuthorDate: Tue Jul 30 18:28:04 2024 -0400

    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 logging import getLogger, StreamHandler, Formatter, 
Filter, \
 
 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 @@ class PatternMatcher:
 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 @@ class FunctionScanner(PatternMatcher):
 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 @@ class ClassScanner(PatternMatcher):
 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:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to