コード例 #1
0
ファイル: pytype_runner.py プロジェクト: yoavtzelnick/pytype
 def make_module(mod):
     full_path = mod.path
     target = mod.short_path
     path = full_path[:-len(target)]
     name = mod.module_name
     # We want to preserve __init__ in the module_name for pytype.
     if os.path.basename(full_path) == '__init__.py':
         name += '.__init__'
     return module_utils.Module(path=path, target=target, name=name)
コード例 #2
0
def resolved_file_to_module(f):
  """Turn an importlab ResolvedFile into a pytype Module."""
  full_path = f.path
  target = f.short_path
  path = full_path[:-len(target)]
  name = f.module_name
  # We want to preserve __init__ in the module_name for pytype.
  if os.path.basename(full_path) == '__init__.py':
    name += '.__init__'
  return module_utils.Module(
      path=path, target=target, name=name, kind=f.__class__.__name__)
コード例 #3
0
 def assert_sorted_modules_equal(self, mod_gen, expected_list):
     for path, target, name, expected_report_errors in expected_list:
         try:
             module, actual_report_errors = next(mod_gen)
         except StopIteration:
             raise AssertionError('Not enough modules')
         self.assertEqual(module, module_utils.Module(path, target, name))
         self.assertEqual(actual_report_errors, expected_report_errors)
     try:
         next(mod_gen)
     except StopIteration:
         pass
     else:
         # Too many modules
         raise AssertionError('Too many modules')
コード例 #4
0
 def get_basic_options(self, report_errors=False):
     module = module_utils.Module('foo', 'bar.py', 'bar')
     args = self.runner.get_pytype_args(module, report_errors)
     return pytype_config.Options(args)