예제 #1
0
 def get_checking_errors(self, python, pytd):
   errorlog = errors.ErrorLog()
   infer.check_types(py_src=textwrap.dedent(python),
                     pytd_src=textwrap.dedent(pytd),
                     py_filename="<inline>",
                     pytd_filename="<inline>",
                     python_version=self.PYTHON_VERSION,
                     errorlog=errorlog,
                     cache_unknowns=True)
   return errorlog
예제 #2
0
 def get_checking_errors(self, python, pytd):
   options = config.Options.create(python_version=self.PYTHON_VERSION,
                                   python_exe=self.PYTHON_EXE)
   errorlog = errors.ErrorLog()
   infer.check_types(py_src=textwrap.dedent(python),
                     pytd_src=textwrap.dedent(pytd),
                     py_filename="<inline>",
                     pytd_filename="<inline>",
                     errorlog=errorlog,
                     options=options,
                     cache_unknowns=True)
   return errorlog
예제 #3
0
 def get_checking_errors(self, python, pytd=None):
   options = config.Options.create(python_version=self.PYTHON_VERSION,
                                   python_exe=self.PYTHON_EXE)
   errorlog = errors.ErrorLog()
   infer.check_types(py_src=textwrap.dedent(python),
                     pytd_src=None if pytd is None else textwrap.dedent(pytd),
                     py_filename="<inline>",
                     pytd_filename="<inline>",
                     errorlog=errorlog,
                     options=options,
                     cache_unknowns=True)
   return errorlog
예제 #4
0
 def get_checking_errors(self, python):
   options = config.Options.create(python_version=self.PYTHON_VERSION,
                                   python_exe=self.PYTHON_EXE)
   errorlog = errors.ErrorLog()
   loader = load_pytd.Loader(self.options.module_name, self.options)
   infer.check_types(py_src=textwrap.dedent(python),
                     loader=loader,
                     py_filename="<inline>",
                     errorlog=errorlog,
                     options=options,
                     cache_unknowns=True)
   return errorlog
예제 #5
0
 def assertNoErrors(self,
                    code,
                    raises=None,
                    pythonpath=(),
                    report_errors=True):
     """Run an inference smoke test for the given code."""
     if raises is not None:
         # TODO(kramm): support this
         log.warning("Ignoring 'raises' parameter to assertNoErrors")
     self.options.tweak(pythonpath=pythonpath)
     errorlog = errors.ErrorLog()
     infer.check_types(textwrap.dedent(code),
                       None,
                       None,
                       None,
                       errorlog=errorlog,
                       options=self.options,
                       cache_unknowns=True)
     if report_errors and len(errorlog):
         errorlog.print_to_stderr()
         self.fail("Inferencer found %d errors" % len(errorlog))