def fix( repos: Iterable[str], *, apply_fix: Callable[[], None], check_fix: Callable[[], None] = _noop_check_fix, config: Config, commit: Commit, autofix_settings: AutofixSettings, ) -> None: assert not autofix_settings.interactive or autofix_settings.jobs == 1 repos = tuple(repos)[:autofix_settings.limit] func = functools.partial( _fix_inner, apply_fix=apply_fix, check_fix=check_fix, config=config, commit=commit, autofix_settings=autofix_settings, ) with mapper.process_mapper(autofix_settings.jobs) as do_map: mapper.exhaust(do_map(func, repos))
import pytest from all_repos import mapper def square(n): return n * n @pytest.mark.parametrize( 'ctx', ( mapper.process_mapper(1), mapper.process_mapper(2), mapper.thread_mapper(1), mapper.thread_mapper(2), ), ) def test_mappers(ctx): with ctx as do_map: assert tuple(do_map(square, (3, 4, 5))) == (9, 16, 25) def test_exhaust(): def gen(): yield 1 yield 2 yield 3 inst = gen() assert next(inst) == 1