def test_remove_duplicates(): errors = [ Error(linter='pep8', text='E701'), Error(linter='pylint', text='C0321') ] errors = list(remove_duplicates(errors)) assert len(errors) == 1
def test_remove_duplicates(): from pylama.errors import Error, remove_duplicates errors = [ Error(source='pycodestyle', text='E701'), Error(source='pylint', text='C0321') ] errors = list(remove_duplicates(errors)) assert len(errors) == 1
def run( path: str, code: str = None, rootdir: Path = CURDIR, options: Namespace = None ) -> List[Error]: """Run code checkers with the given params. :param path: (str) A file's path. """ path = op.relpath(path, rootdir) with RunContext(path, code, options) as ctx: if ctx.skip: LOGGER.info("Skip checking for path: %s", path) else: for lname in ctx.linters or LINTERS: linter_cls = LINTERS.get(lname) if not linter_cls: continue linter = linter_cls() LOGGER.info("Run [%s] %s", lname, path) if isinstance(linter, LinterV2): linter.run_check(ctx) else: for err_info in linter.run( ctx.temp_filename, code=ctx.source, params=ctx.get_params(lname) ): ctx.push(source=lname, **err_info) if not ctx.errors: return ctx.errors errors = list(remove_duplicates(ctx.errors)) sorter = default_sorter if options and options.sort: sort = options.sort sorter = lambda err: (sort.get(err.etype, 999), err.lnum) return sorted(errors, key=sorter)
def test_remove_duplicates(): errors = [Error(linter='pep8', text='E701'), Error(linter='pylint', text='C0321')] errors = list(remove_duplicates(errors)) assert len(errors) == 1