Repository: google/pytype

Issue:
Remove ".py" report
Part of #111 


Discussion:
Thanks! It looks like pytype/tools/analyze_project/pytype_runner_test.py needs to be updated.
Actually, there's one more place in pytype that probably needs to be changed: https://github.com/google/pytype/blob/master/pytype/tools/analyze_project/main.py#L77. If `import_graph.unreadable files` is now going to include all files regardless of extension, then we shouldn't report an error unless an unreadable file is a Python file.

I think something like the following would work:
```
try:
  ...
  unreadable_inputs = conf.inputs & import_graph.unreadable_files
  unreadable_python_inputs = {file for file in unreadable_inputs if file.endswith('.py')}
      assert not unreadable_python_inputs, '\n  '.join(
          ['Unparseable in Python %s:' % conf.python_version] +
        sorted(unreadable_python_inputs))
except ...:
  ...
conf.inputs -= unreadable_inputs
```
@rchen152 Thanks for all your inputs, I guess it should work now.
Thanks for sending the additional PR. For this one, the failing test still needs to be updated. It looks like the broken test cases are TestYieldSortedModules.test_non_py_dep and TestGetModuleAction.test_skip in pytype/tools/analyze_project/pytype_runner_test.py. Since they're testing behavior that this change is removing, I think you can just delete them.
@rchen152 I hope #207 will do it.
@rchen152 I guess it will keep on failing until #207 is merged.
Could you copy the changes from https://github.com/google/pytype/pull/207 into this PR instead? It's better to have the test removal done together with the motivating change; also, if they're submitted separately, I think you'd have to rebase this PR on top of the master branch.
@rchen152 Sure, I will.
@rchen152 It's done.
@rchen152 Sure, Thanks!!

Resolving patch:
diff --git a/pytype/tools/analyze_project/pytype_runner.py b/pytype/tools/analyze_project/pytype_runner.py
--- a/pytype/tools/analyze_project/pytype_runner.py
+++ b/pytype/tools/analyze_project/pytype_runner.py
@@ -196,9 +196,6 @@ def get_module_action(self, module):
     else:
       action = Action.INFER
       report = logging.info
-    if not f.endswith('.py'):
-      report('skipped: non-Python file %s', f)
-      return None
     # For builtin and system files, do not attempt to generate a pyi.
     if module.kind in ('Builtin', 'System'):
       action = Action.GENERATE_DEFAULT


Test patch:
diff --git a/pytype/tools/analyze_project/pytype_runner_test.py b/pytype/tools/analyze_project/pytype_runner_test.py
--- a/pytype/tools/analyze_project/pytype_runner_test.py
+++ b/pytype/tools/analyze_project/pytype_runner_test.py
@@ -252,10 +252,6 @@ def test_generate_default(self):
         runner.get_module_action(Module('', 'foo.py', 'foo', 'System')),
         pytype_runner.Action.GENERATE_DEFAULT)
 
-  def test_skip(self):
-    runner = make_runner([], [], self.parser.config_from_defaults())
-    self.assertIsNone(runner.get_module_action(Module('', 'foo.cc', 'foo')))
-
 
 class TestYieldSortedModules(TestBase):
   """Tests for PytypeRunner.yield_sorted_modules()."""
@@ -320,14 +316,6 @@ def test_cycle(self):
          (dep, Action.INFER, (dep, src), Stage.SECOND_PASS),
          (src, Action.CHECK, (dep, src), Stage.SECOND_PASS)])
 
-  def test_non_py_dep(self):
-    conf = self.parser.config_from_defaults()
-    d = self.normalize('foo/')
-    conf.pythonpath = [d]
-    dep = Module(d, 'bar.so', 'bar')
-    runner = make_runner([], [((dep,), ())], conf)
-    self.assert_sorted_modules_equal(runner.yield_sorted_modules(), [])
-
   def test_system_dep(self):
     conf = self.parser.config_from_defaults()
     d = self.normalize('foo/')