File: scoping_policy.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 (49 lines) | stat: -rw-r--r-- 1,489 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
from enum import auto
from types import FunctionType, ModuleType
from typing import overload, Literal, Callable, TypedDict
from .line_profiler_utils import StringEnum


class ScopingPolicy(StringEnum):
    CHILDREN = auto()
    DESCENDANTS = auto()
    SIBLINGS = auto()
    NONE = auto()

    @overload
    def get_filter(
            self,
            namespace: type | ModuleType,
            obj_type: Literal['func']) -> Callable[[FunctionType], bool]:
        ...

    @overload
    def get_filter(
            self,
            namespace: type | ModuleType,
            obj_type: Literal['class']) -> Callable[[type], bool]:
        ...

    @overload
    def get_filter(
            self,
            namespace: type | ModuleType,
            obj_type: Literal['module']) -> Callable[[ModuleType], bool]:
        ...

    @classmethod
    def to_policies(
        cls,
        policies: (str | 'ScopingPolicy' | 'ScopingPolicyDict'
                   | None) = None) -> '_ScopingPolicyDict':
        ...


ScopingPolicyDict = TypedDict('ScopingPolicyDict',
                              {'func': str | ScopingPolicy,
                               'class': str | ScopingPolicy,
                               'module': str | ScopingPolicy})
_ScopingPolicyDict = TypedDict('_ScopingPolicyDict',
                               {'func': str | ScopingPolicy,
                                'class': str | ScopingPolicy,
                                'module': str | ScopingPolicy})