diff --git a/pytype/pytd/pytd_utils.py b/pytype/pytd/pytd_utils.py index ddac0a394..fa50cecb6 100644 --- a/pytype/pytd/pytd_utils.py +++ b/pytype/pytd/pytd_utils.py @@ -185,8 +185,7 @@ def match(self, t1, t2, *args, **kwargs): if f: return f(t1, t2, *args, **kwargs) else: - # TODO(b/117657518): Remove the disable once the pytype bug is fixed - return self.default_match(t1, t2, *args, **kwargs) # pytype: disable=wrong-arg-count + return self.default_match(t1, t2, *args, **kwargs) def CanonicalOrdering(n, sort_signatures=False): diff --git a/pytype/tests/test_base.py b/pytype/tests/test_base.py index a554274c2..0d8fb878e 100644 --- a/pytype/tests/test_base.py +++ b/pytype/tests/test_base.py @@ -100,6 +100,7 @@ class BaseTest(unittest.TestCase): @classmethod def setUpClass(cls): + super(BaseTest, cls).setUpClass() # We use class-wide loader to avoid creating a new loader for every test # method if not required. cls._loader = None @@ -156,6 +157,7 @@ def t(name): # pylint: disable=invalid-name (cls.nothing, cls.nothing)) def setUp(self): + super(BaseTest, self).setUp() # The test class (type of |self|) constructor is required to initialize the # 'python_version' attribute. assert hasattr(self, "python_version") @@ -284,11 +286,10 @@ def assertHasOnlySignatures(self, func, *sigs): format(name=func.name, sig=self.PrintSignature(parameter_types, return_type), func=pytd.Print(func))) - self.assertEqual(len(func.signatures), len(sigs), - "{func} has the wrong number of signatures ({has}), " - "expected {expect}". - format(func=func, - has=len(func.signatures), expect=len(sigs))) + msg = ("{func} has the wrong number of signatures ({has}), " + "expected {expect}".format( + func=func, has=len(func.signatures), expect=len(sigs))) + self.assertEqual(len(func.signatures), len(sigs), msg) def assertHasSignature(self, func, parameter_types, return_type): if not self.HasSignature(func, parameter_types, return_type): diff --git a/pytype/tools/analyze_project/main.py b/pytype/tools/analyze_project/main.py index 4eab45f4c..63a265029 100755 --- a/pytype/tools/analyze_project/main.py +++ b/pytype/tools/analyze_project/main.py @@ -75,13 +75,17 @@ def main(): import_graph = importlab.graph.ImportGraph.create( env, conf.inputs, trim=True) unreadable_inputs = conf.inputs & import_graph.unreadable_files - assert not unreadable_inputs, '\n '.join( + unreadable_python_inputs = { + filename for filename in unreadable_inputs if filename.endswith('.py')} + assert not unreadable_python_inputs, '\n '.join( ['Unparseable in Python %s:' % conf.python_version] + - sorted(unreadable_inputs)) + sorted(unreadable_python_inputs)) except Exception as e: # pylint: disable=broad-except - logging.critical('Cannot parse input files:\n%s', str(e)) + logging.critical('Cannot parse input files:\n%s', e) sys.exit(1) + conf.inputs -= unreadable_inputs + if args.tree: print('Source tree:') importlab.output.print_tree(import_graph) diff --git a/pytype/tools/analyze_project/pytype_runner_test.py b/pytype/tools/analyze_project/pytype_runner_test.py index 869e8c54a..11ae340da 100644 --- a/pytype/tools/analyze_project/pytype_runner_test.py +++ b/pytype/tools/analyze_project/pytype_runner_test.py @@ -68,6 +68,7 @@ class TestDepsFromImportGraph(unittest.TestCase): """Test deps_from_import_graph.""" def setUp(self): + super(TestDepsFromImportGraph, self).setUp() init = ImportlabModule('/foo/bar/__init__.py', 'bar/__init__.py', 'bar') a = ImportlabModule('/foo/bar/a.py', 'bar/a.py', 'bar.a') b = ImportlabModule('/foo/bar/b.py', 'bar/b.py', 'bar.b') @@ -104,6 +105,7 @@ class TestBase(unittest.TestCase): @classmethod def setUpClass(cls): + super(TestBase, cls).setUpClass() cls.parser = parse_args.make_parser() @@ -111,6 +113,7 @@ class TestCustomOptions(TestBase): """Test PytypeRunner.set_custom_options.""" def setUp(self): + super(TestCustomOptions, self).setUp() self.conf = self.parser.config_from_defaults() # --disable tests a flag with a string value. @@ -180,6 +183,7 @@ class TestGetRunCmd(TestBase): """Test PytypeRunner.get_pytype_command_for_ninja().""" def setUp(self): + super(TestGetRunCmd, self).setUp() self.runner = make_runner([], [], self.parser.config_from_defaults()) def get_options(self, args): diff --git a/pytype/typegraph/cfg_test.py b/pytype/typegraph/cfg_test.py index c577bece0..15206c0fc 100644 --- a/pytype/typegraph/cfg_test.py +++ b/pytype/typegraph/cfg_test.py @@ -19,7 +19,7 @@ def testSimpleGraph(self): self.assertEqual(0, n1.id) self.assertEqual("foo", n1.name) self.assertEqual(len(n1.outgoing), 2) - self.assertEqual(len(n2.outgoing), 0) + self.assertEqual(len(n2.outgoing), 0) # pylint: disable=g-generic-assert self.assertEqual(len(n3.outgoing), 1) self.assertEqual(len(n2.incoming), 1) self.assertEqual(len(n3.incoming), 1) @@ -763,7 +763,7 @@ def testPruneTwoOrigins(self): b = x.AddBinding(1) b.AddOrigin(source_set=[], where=n1) b.AddOrigin(source_set=[], where=n2) - self.assertEqual(1, len([v.data for v in x.Bindings(n3)])) + self.assertEqual(len([v.data for v in x.Bindings(n3)]), 1) def testHiddenConflict3(self): p = cfg.Program()