-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_stubs.pyi
More file actions
134 lines (118 loc) · 4.57 KB
/
_stubs.pyi
File metadata and controls
134 lines (118 loc) · 4.57 KB
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
# File generated with docstub
import enum
import logging
from collections.abc import Sequence
from dataclasses import dataclass
from functools import wraps
from pathlib import Path
from typing import ClassVar, Literal
import libcst as cst
import libcst.matchers as cstm
from _typeshed import Incomplete
from ._analysis import PyImport, TypeMatcher
from ._docstrings import (
Annotation,
DocstringAnnotations,
DoctypeTransformer,
FallbackAnnotation,
)
from ._report import ContextReporter
from ._utils import module_name_from_path, update_with_add_values
logger: logging.Logger
def try_format_stub(stub: str) -> str: ...
class ScopeType(enum.StrEnum):
MODULE = "module"
CLASS = "class"
FUNC = "func"
METHOD = "method"
CLASSMETHOD = "classmethod"
STATICMETHOD = "staticmethod"
_dataclass_name: cstm.Name
_dataclass_matcher: cstm.ClassDef
@dataclass(slots=True, frozen=True)
class _Scope:
type: ScopeType
node: cst.CSTNode | None = ...
@property
def has_self_or_cls(self) -> bool: ...
@property
def is_method(self) -> bool: ...
@property
def is_class_init(self) -> bool: ...
@property
def is_dataclass(self) -> bool: ...
def _get_docstring_node(
node: cst.FunctionDef | cst.ClassDef | cst.Module,
) -> tuple[cst.SimpleString | cst.ConcatenatedString | None, str | None]: ...
def _log_error_with_line_context(cls: Py2StubTransformer) -> Py2StubTransformer: ...
def _docstub_comment_directives(cls: Py2StubTransformer) -> Py2StubTransformer: ...
def _inline_node_as_code(node: cst.CSTNode) -> str: ...
class Py2StubTransformer(cst.CSTTransformer):
transformer: DoctypeTransformer
METADATA_DEPENDENCIES: ClassVar[tuple]
_body_replacement: ClassVar[cst.SimpleStatementSuite]
_Annotation_Incomplete: ClassVar[cst.Annotation]
_Annotation_None: ClassVar[cst.Annotation]
def __init__(self, *, matcher: TypeMatcher | None = ...) -> None: ...
@property
def current_source(self) -> Path: ...
@current_source.setter
def current_source(self, value: Path) -> None: ...
@property
def is_inside_function_def(self) -> bool: ...
def python_to_stub(self, source: str, *, module_path: Path | None = ...) -> str: ...
def collect_stats(
self, *, reset_after: bool = ...
) -> dict[str, int | list[str]]: ...
def visit_ClassDef(self, node: cst.ClassDef) -> Literal[True]: ...
def leave_ClassDef(
self, original_node: cst.ClassDef, updated_node: cst.ClassDef
) -> cst.ClassDef: ...
def visit_FunctionDef(self, node: cst.FunctionDef) -> Literal[True]: ...
def visit_IndentedBlock(self, node: cst.IndentedBlock) -> bool: ...
def visit_SimpleStatementSuite(self, node: cst.SimpleStatementSuite) -> bool: ...
def leave_FunctionDef(
self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef
) -> cst.FunctionDef: ...
def leave_Param(
self, original_node: cst.Param, updated_node: cst.Param
) -> cst.Param: ...
def leave_Expr(
self, original_node: cst.Expr, updated_node: cst.Expr
) -> cst.RemovalSentinel: ...
def leave_Comment(
self, original_node: cst.Comment, updated_node: cst.Comment
) -> cst.Comment: ...
def leave_Assign(
self, original_node: cst.Assign, updated_node: cst.Assign
) -> cst.Assign | cst.FlattenSentinel: ...
def leave_AnnAssign(
self, original_node: cst.AnnAssign, updated_node: cst.AnnAssign
) -> cst.AnnAssign: ...
def visit_Module(self, node: cst.Module) -> Literal[True]: ...
def leave_Module(
self, original_node: cst.Module, updated_node: cst.Module
) -> cst.Module: ...
def visit_Lambda(self, node: cst.Lambda) -> Literal[False]: ...
def leave_Decorator(
self, original_node: cst.Decorator, updated_node: cst.Decorator
) -> cst.Decorator | cst.RemovalSentinel: ...
@staticmethod
def _parse_imports(
imports: set[PyImport], *, current_module: str | None = ...
) -> tuple[cst.SimpleStatementLine, ...]: ...
def _function_type(self, func_def: cst.FunctionDef) -> ScopeType: ...
def _annotations_from_node(
self, node: cst.FunctionDef | cst.ClassDef | cst.Module
) -> DocstringAnnotations: ...
def _create_annotated_assign(
self,
*,
name: str,
trailing_semicolon: bool = ...,
reporter: ContextReporter | None = ...
) -> cst.AnnAssign: ...
def _insert_instance_attributes(
self, updated_node: cst.ClassDef, attributes: dict[str, Annotation]
) -> cst.ClassDef: ...
def _reporter_with_ctx(self, node: cst.CSTNode) -> ContextReporter: ...