failure_count = 0 for filename in sources: failure_count += self.check_file(filename) if failure_count > 0 and self.options.fail: raise TaskError('{} Python Style issues found'.format(failure_count), exit_code=1) return failure_count def execute(self): """Run Checkstyle on all found source files.""" if self.options.skip: return with self.invalidated(self.context.targets(self._is_checked)) as invalidation_check: sources = self.calculate_sources([vt.target for vt in invalidation_check.invalid_vts]) if sources: return self.checkstyle(sources) def calculate_sources(self, targets): """Generate a set of source files from the given targets.""" sources = set() for target in targets: sources.update( source for source in target.sources_relative_to_buildroot() if source.endswith(self._PYTHON_SOURCE_EXTENSION) ) return sources register_plugins(PythonCheckStyleTask)
if failure_count > 0 and self.options.fail: raise TaskError( '{} Python Style issues found. For import order related issues, please try ' '`./pants fmt.isort <targets>`'.format(failure_count)) return failure_count def execute(self): """Run Checkstyle on all found source files.""" if self.options.skip: return with self.invalidated(self.context.targets( self._is_checked)) as invalidation_check: sources = self.calculate_sources( [vt.target for vt in invalidation_check.invalid_vts]) if sources: return self.checkstyle(sources) def calculate_sources(self, targets): """Generate a set of source files from the given targets.""" sources = set() for target in targets: sources.update( source for source in target.sources_relative_to_buildroot() if source.endswith(self._PYTHON_SOURCE_EXTENSION)) return sources register_plugins(PythonCheckStyleTask)