Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/libcst/codemod/_dummy_pool.py: 64%

14 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-09-25 06:43 +0000

1# Copyright (c) Meta Platforms, Inc. and affiliates. 

2# 

3# This source code is licensed under the MIT license found in the 

4# LICENSE file in the root directory of this source tree. 

5 

6from types import TracebackType 

7from typing import Callable, Generator, Iterable, Optional, Type, TypeVar 

8 

9RetT = TypeVar("RetT") 

10ArgT = TypeVar("ArgT") 

11 

12 

13class DummyPool: 

14 """ 

15 Synchronous dummy `multiprocessing.Pool` analogue. 

16 """ 

17 

18 def __init__(self, processes: Optional[int] = None) -> None: 

19 pass 

20 

21 def imap_unordered( 

22 self, 

23 func: Callable[[ArgT], RetT], 

24 iterable: Iterable[ArgT], 

25 chunksize: Optional[int] = None, 

26 ) -> Generator[RetT, None, None]: 

27 for args in iterable: 

28 yield func(args) 

29 

30 def __enter__(self) -> "DummyPool": 

31 return self 

32 

33 def __exit__( 

34 self, 

35 exc_type: Optional[Type[Exception]], 

36 exc: Optional[Exception], 

37 tb: Optional[TracebackType], 

38 ) -> None: 

39 pass