def run_pytype(self, module, report_errors): """Run pytype over a single module.""" # Create the output subdirectory for this file. target_dir = os.path.join(self.pyi_dir, os.path.dirname(module.target)) try: file_utils.makedirs(target_dir) except OSError: logging.error('Could not create output directory: %s', target_dir) return if report_errors: print('%s' % module.target) else: print('%s*' % module.target) args = self.get_pytype_args(module, report_errors) logging.info('Running: pytype %s %s', ' '.join(args), self.custom_options) # TODO(rechen): Do we want to get rid of the --nofail option and use a # try/except here instead? We'd control the failure behavior (e.g. we could # potentially bring back the .errors file, or implement an "abort on first # error" flag for quick iterative typechecking). with debug.save_logging_level( ): # pytype_config changes the logging level options = pytype_config.Options(args) # TODO(rechen): Do this tweaking in get_pytype_args so it can be tested. if report_errors: options.tweak(**self.custom_options) io.process_one_file(options)
def make_imports_dir(self): try: file_utils.makedirs(self.imports_dir) except OSError: logging.error('Could not create imports directory: %s', self.imports_dir) return False return True
def create_output_dir(self, module): # Create the output subdirectory for this file. target_dir = os.path.dirname(self._output_file(module)) try: file_utils.makedirs(target_dir) except OSError: logging.error('Could not create output directory: %s', target_dir) return return target_dir
def makedirs_or_die(path, message): try: file_utils.makedirs(path) except OSError: logging.critical('%s: %s', message, path) sys.exit(1)