Skip to content

Commit

Permalink
PROTON-2844: [Python] use more idiomatic type test
Browse files Browse the repository at this point in the history
This gets rid of a warning from recent python linter.
  • Loading branch information
astitcher committed Aug 1, 2024
1 parent 4c5adb5 commit da3096b
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions python/tests/proton_tests/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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)):
Expand All @@ -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:
Expand Down

0 comments on commit da3096b

Please sign in to comment.