File: profiler_mixin.pyi

package info (click to toggle)
python-line-profiler 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,256 kB
  • sloc: python: 8,119; sh: 810; ansic: 297; makefile: 14
file content (222 lines) | stat: -rw-r--r-- 5,219 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
from functools import cached_property, partial, partialmethod
from types import (CodeType, FunctionType, MethodType,
                   BuiltinFunctionType, BuiltinMethodType,
                   ClassMethodDescriptorType, MethodDescriptorType,
                   MethodWrapperType, WrapperDescriptorType)
from typing import (TYPE_CHECKING,
                    Any, Callable, Dict, List, Mapping, Protocol, TypeVar)
try:
    from typing import (  # type: ignore[attr-defined]  # noqa: F401
        ParamSpec)
except ImportError:  # Python < 3.10
    from typing_extensions import ParamSpec  # noqa: F401
try:
    from typing import (  # type: ignore[attr-defined]  # noqa: F401
        Self)
except ImportError:  # Python < 3.11
    from typing_extensions import Self  # noqa: F401
try:
    from typing import (  # type: ignore[attr-defined]  # noqa: F401
        TypeIs)
except ImportError:  # Python < 3.13
    from typing_extensions import TypeIs  # noqa: F401
from ._line_profiler import label


T = TypeVar('T', bound=type)
T_co = TypeVar('T_co', covariant=True)
R = TypeVar('R')
PS = ParamSpec('PS')

if TYPE_CHECKING:
    class CythonCallable(Protocol[PS, T_co]):
        def __call__(self, *args: PS.args, **kwargs: PS.kwargs) -> T_co:
            ...

        @property
        def __code__(self) -> CodeType:
            ...

        @property
        def func_code(self) -> CodeType:
            ...

        @property
        def __name__(self) -> str:
            ...

        @property
        def func_name(self) -> str:
            ...

        @property
        def __qualname__(self) -> str:
            ...

        @property
        def __doc__(self) -> str | None:
            ...

        @__doc__.setter
        def __doc__(self, doc: str | None) -> None:
            ...

        @property
        def func_doc(self) -> str | None:
            ...

        @property
        def __globals__(self) -> Dict[str, Any]:
            ...

        @property
        def func_globals(self) -> Dict[str, Any]:
            ...

        @property
        def __dict__(self) -> Dict[str, Any]:
            ...

        @__dict__.setter
        def __dict__(self, dict: Dict[str, Any]) -> None:
            ...

        @property
        def func_dict(self) -> Dict[str, Any]:
            ...

        @property
        def __annotations__(self) -> Dict[str, Any]:
            ...

        @__annotations__.setter
        def __annotations__(self, annotations: Dict[str, Any]) -> None:
            ...

        @property
        def __defaults__(self):
            ...

        @property
        def func_defaults(self):
            ...

        @property
        def __kwdefaults__(self):
            ...

        @property
        def __closure__(self):
            ...

        @property
        def func_closure(self):
            ...


else:
    CythonCallable = type(label)

CLevelCallable = TypeVar('CLevelCallable',
                         BuiltinFunctionType, BuiltinMethodType,
                         ClassMethodDescriptorType, MethodDescriptorType,
                         MethodWrapperType, WrapperDescriptorType)


def is_c_level_callable(func: Any) -> TypeIs[CLevelCallable]:
    ...


def is_cython_callable(func: Any) -> TypeIs[CythonCallable]:
    ...


def is_classmethod(f: Any) -> TypeIs[classmethod]:
    ...


def is_staticmethod(f: Any) -> TypeIs[staticmethod]:
    ...


def is_boundmethod(f: Any) -> TypeIs[MethodType]:
    ...


def is_partialmethod(f: Any) -> TypeIs[partialmethod]:
    ...


def is_partial(f: Any) -> TypeIs[partial]:
    ...


def is_property(f: Any) -> TypeIs[property]:
    ...


def is_cached_property(f: Any) -> TypeIs[cached_property]:
    ...


class ByCountProfilerMixin:
    def get_underlying_functions(self, func) -> List[FunctionType]:
        ...

    def wrap_callable(self, func):
        ...

    def wrap_classmethod(self, func: classmethod) -> classmethod:
        ...

    def wrap_staticmethod(self, func: staticmethod) -> staticmethod:
        ...

    def wrap_boundmethod(self, func: MethodType) -> MethodType:
        ...

    def wrap_partialmethod(self, func: partialmethod) -> partialmethod:
        ...

    def wrap_partial(self, func: partial) -> partial:
        ...

    def wrap_property(self, func: property) -> property:
        ...

    def wrap_cached_property(self, func: cached_property) -> cached_property:
        ...

    def wrap_async_generator(self, func: FunctionType) -> FunctionType:
        ...

    def wrap_coroutine(self, func: FunctionType) -> FunctionType:
        ...

    def wrap_generator(self, func: FunctionType) -> FunctionType:
        ...

    def wrap_function(self, func: Callable) -> FunctionType:
        ...

    def wrap_class(self, func: T) -> T:
        ...

    def run(self, cmd: str) -> Self:
        ...

    def runctx(self,
               cmd: str,
               globals: Dict[str, Any] | None,
               locals: Mapping[str, Any] | None) -> Self:
        ...

    def runcall(self, func: Callable[PS, R], /,
                *args: PS.args, **kw: PS.kwargs) -> R:
        ...

    def __enter__(self) -> Self:
        ...

    def __exit__(self, *_, **__) -> None:
        ...