# HG changeset patch # User Andrey Skvortsov # Date 1507633306 -10800 # Node ID c4ba411f8c8995a79560eaa067daf4aa33b0e765 # Parent 410a3bcbeb29a628f1d8e6f97683aa09e4c98528 fix pylint warning '(unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck' diff -r 410a3bcbeb29 -r c4ba411f8c89 PLCGenerator.py --- a/PLCGenerator.py Tue Oct 10 13:49:13 2017 +0300 +++ b/PLCGenerator.py Tue Oct 10 14:01:46 2017 +0300 @@ -995,7 +995,7 @@ uncomputed_index = range(len(paths)) factorized_paths = [] for num, path in enumerate(paths): - if type(path) == ListType: + if isinstance(path, ListType): if len(path) > 1: str_path = str(path[-1:]) same_paths.setdefault(str_path, []) @@ -1261,7 +1261,7 @@ paths.append([variable, tuple(factorized_paths)]) else: paths.append([variable] + factorized_paths) - elif type(result[0]) == ListType: + elif isinstance(result[0], ListType): paths.append([variable] + result[0]) elif result[0] is not None: paths.append([variable, result[0]]) @@ -1272,7 +1272,7 @@ return paths def ComputePaths(self, paths, first=False): - if type(paths) == TupleType: + if isinstance(paths, TupleType): if None in paths: return [("TRUE", ())] else: @@ -1281,7 +1281,7 @@ return JoinList([(" OR ", ())], vars) else: return [("(", ())] + JoinList([(" OR ", ())], vars) + [(")", ())] - elif type(paths) == ListType: + elif isinstance(paths, ListType): vars = [self.ComputePaths(path) for path in paths] return JoinList([(" AND ", ())], vars) elif paths is None: diff -r 410a3bcbeb29 -r c4ba411f8c89 tests/tools/check_source.sh --- a/tests/tools/check_source.sh Tue Oct 10 13:49:13 2017 +0300 +++ b/tests/tools/check_source.sh Tue Oct 10 14:01:46 2017 +0300 @@ -239,6 +239,7 @@ enable=$enable,C0413 # (wrong-import-position) Import "import X" should be placed at the top of the module enable=$enable,E1305 # (too-many-format-args) Too many arguments for format string enable=$enable,E0704 # (misplaced-bare-raise) The raise statement is not inside an except clause + enable=$enable,C0123 # (unidiomatic-typecheck) Using type() instead of isinstance() for a typecheck. # enable= options= diff -r 410a3bcbeb29 -r c4ba411f8c89 util/misc.py --- a/util/misc.py Tue Oct 10 13:49:13 2017 +0300 +++ b/util/misc.py Tue Oct 10 14:01:46 2017 +0300 @@ -48,7 +48,7 @@ def GetClassImporter(classpath): - if type(classpath) == str: + if isinstance(classpath, str): def fac(): mod = __import__(classpath.rsplit('.', 1)[0]) return reduce(getattr, classpath.split('.')[1:], mod)