|
8 | 8 | import asynq
|
9 | 9 | import contextlib
|
10 | 10 | from dataclasses import dataclass, field
|
11 |
| -import enum |
12 | 11 | import qcore
|
13 | 12 | import inspect
|
14 | 13 | import types
|
15 |
| -from typing import Sequence, Any, Callable, List, Optional, Iterable |
16 |
| - |
17 |
| -from pyanalyze.options import Options, PyObjectSequenceOption, StringSequenceOption |
| 14 | +from typing import Iterator, Sequence, Any, Callable, Optional |
18 | 15 |
|
19 | 16 | from .config import Config
|
20 | 17 | from .error_code import ErrorCode
|
| 18 | +from .functions import AsyncFunctionKind |
| 19 | +from .options import Options, PyObjectSequenceOption, StringSequenceOption |
21 | 20 | from .safe import safe_getattr, safe_hasattr
|
22 | 21 | from .stacked_scopes import Composite
|
23 | 22 | from .value import AnnotatedValue, Value, KnownValue, TypedValue, UnboundMethodValue
|
24 | 23 |
|
25 | 24 |
|
26 |
| -class AsyncFunctionKind(enum.Enum): |
27 |
| - non_async = 0 |
28 |
| - normal = 1 |
29 |
| - async_proxy = 2 |
30 |
| - pure = 3 |
31 |
| - |
32 |
| - |
33 |
| -@dataclass(frozen=True) |
34 |
| -class FunctionInfo: |
35 |
| - async_kind: AsyncFunctionKind |
36 |
| - is_classmethod: bool # has @classmethod |
37 |
| - is_staticmethod: bool # has @staticmethod |
38 |
| - is_decorated_coroutine: bool # has @asyncio.coroutine |
39 |
| - is_overload: bool # typing.overload or pyanalyze.extensions.overload |
40 |
| - # a list of pairs of (decorator function, applied decorator function). These are different |
41 |
| - # for decorators that take arguments, like @asynq(): the first element will be the asynq |
42 |
| - # function and the second will be the result of calling asynq(). |
43 |
| - decorators: List[Any] |
44 |
| - |
45 |
| - |
46 | 25 | class ClassesCheckedForAsynq(PyObjectSequenceOption[type]):
|
47 | 26 | """Normally, asynq calls to asynq functions are only enforced in functions that are already
|
48 | 27 | asynq. In subclasses of classes listed here, all asynq functions must be called asynq."""
|
@@ -98,7 +77,7 @@ def set_func_name(
|
98 | 77 | name: str,
|
99 | 78 | async_kind: AsyncFunctionKind = AsyncFunctionKind.non_async,
|
100 | 79 | is_classmethod: bool = False,
|
101 |
| - ) -> Iterable[None]: |
| 80 | + ) -> Iterator[None]: |
102 | 81 | """Sets the current function name for async data collection."""
|
103 | 82 | # Override current_func_name only if this is the outermost function, so that data access
|
104 | 83 | # within nested functions is attributed to the outer function. However, for async inner
|
|
0 commit comments