def run(self) -> Generator[Tuple[int, int, str, type], None, None]:
        """
        Runs the checker.

        ``fix_file()`` only mutates the buffer object.
        It is the only way to find out if some error happened.
        """
        if self.filename != STDIN:
            buffer = StringIO()
            fix_file(self.filename, _Options(), buffer)
            traceback = buffer.getvalue()

            if traceback:
                yield 1, 0, self._error(traceback), type(self)
    def runtest(self):
        out = StringIO()

        class Args():
            in_place = False
        args = Args()

        eradicate.fix_file(str(self.fspath), args, out)

        out.seek(0)
        errors = out.read()

        if errors:
            raise EradicateError(errors, 'error')
        # update mtime only if test passed
        # otherwise failures would not be re-run next time
        self.config._eradicatemtimes[str(self.fspath)] = (self._eradicatemtime, [])
Beispiel #3
0
    def run(self, path, **meta):
        """Lint the file. Return an array of error dicts if appropriate."""

        out = StringIO()

        class Args():
            in_place = False
        args = Args()

        fix_file(path, args, out)

        out.seek(0)
        errors = out.read()

        if errors:
            return errors
        else:
            return []