Debian Codegraph @

tests/fixtures/parsing/restructured_text/attributes.py

raw
1 """
2 Module docstring.
3
4 :var DESCRIBED_IN_MODULE_DOCSTRING: Described in module docstring.
5 :var DESCRIBED_AND_ANNOTATED_IN_MODULE_DOCSTRING: Described and annotated in module docstring.
6 :vartype DESCRIBED_AND_ANNOTATED_IN_MODULE_DOCSTRING: bool
7 :var DESCRIBED_IN_BOTH: Described in both.
8 :var DESCRIBED_AND_ANNOTATED_IN_BOTH: Described and annotated in both.
9 :vartype DESCRIBED_AND_ANNOTATED_IN_BOTH: bool
10 """
11
12 from datetime import datetime
13 from typing import Optional, Tuple
14
15 from marshmallow import Schema, fields
16 from pydantic import BaseModel
17
18 NO_DOC_NO_TYPE = 0
19
20 NO_TYPE = 1
21 """No type."""
22
23 NO_DOC_NO_VALUE: int
24
25 NO_VALUE: str
26 """No value."""
27
28 NO_DOC: int = 2
29
30 FULL: int = 3
31 """Full."""
32
33 DESCRIBED_IN_MODULE_DOCSTRING: bool = True
34 DESCRIBED_AND_ANNOTATED_IN_MODULE_DOCSTRING = True
35
36 DESCRIBED_IN_BOTH: bool = True
37 """Described in both."""
38
39 DESCRIBED_AND_ANNOTATED_IN_BOTH: bool = True
40 """Described and annotated in both."""
41
42 COMPLEX_TYPE: Optional[Tuple[int, str]] = None
43 """Complex type."""
44
45
46 ATTRIBUTE_C1: "C"
47 """Forward reference for type."""
48
49
50 ATTRIBUTE_C2: Optional["C"] = None
51 """Optional forward reference for type."""
52
53
54 class C:
55 """
56 Class doctring.
57
58 :cvar DESCRIBED_IN_CLASS_DOCSTRING: Described in class docstring.
59 :cvar DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING: Described and annotated in class docstring.
60 :vartype DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING: bool
61 :cvar DESCRIBED_IN_BOTH: Described in both.
62 :cvar DESCRIBED_AND_ANNOTATED_IN_BOTH: Described and annotated in both.
63 :vartype DESCRIBED_AND_ANNOTATED_IN_BOTH: bool
64
65 :var described_in_class_docstring: Described in class docstring.
66 :var described_and_annotated_in_class_docstring: Described and annotated in class docstring.
67 :vartype described_and_annotated_in_class_docstring: bool
68 :var described_in_both: Described in both.
69 :var described_and_annotated_in_both: Described and annotated in both.
70 :vartype described_and_annotated_in_both: bool
71 """
72
73 IN_CLASS = 0
74 """In class."""
75
76 DESCRIBED_IN_CLASS_DOCSTRING: bool = True
77 DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING = True
78
79 DESCRIBED_IN_BOTH: bool = True
80 """Described in both."""
81
82 DESCRIBED_AND_ANNOTATED_IN_BOTH: bool = True
83 """Described and annotated in both."""
84
85 both_class_and_instance_attribute: Optional[bool] = None
86
87 def __init__(self):
88 self.in_init = True
89 """In init."""
90
91 self.annotated_in_init: bool = True
92 """Annotated in init."""
93
94 self.described_in_class_docstring: bool = True
95 self.described_and_annotated_in_class_docstring = True
96
97 self.described_in_both: bool = True
98 """Described in both."""
99
100 self.described_and_annotated_in_both: bool = True
101 """Described and annotated in both."""
102
103 non_attribute: bool = True
104 """Non attribute."""
105
106 if not self.both_class_and_instance_attribute:
107 self.both_class_and_instance_attribute = True
108
109
110 class D:
111 def __init__(self):
112 """
113 Init doctring.
114
115 :var described_in_class_docstring: Described in class docstring.
116 :var described_and_annotated_in_class_docstring: Described and annotated in class docstring.
117 :vartype described_and_annotated_in_class_docstring: bool
118 :var described_in_both: Described in both.
119 :var described_and_annotated_in_both: Described and annotated in both.
120 :vartype described_and_annotated_in_both: bool
121 """
122 self.in_init = True
123 """In init."""
124
125 self.annotated_in_init: bool = True
126 """Annotated in init."""
127
128 self.described_in_class_docstring: bool = True
129 self.described_and_annotated_in_class_docstring = True
130
131 self.described_in_both: bool = True
132 """Described in both."""
133
134 self.described_and_annotated_in_both: bool = True
135 """Described and annotated in both."""
136
137 non_attribute: bool = True
138 """Non attribute."""
139
140 if not self.both_class_and_instance_attribute:
141 self.both_class_and_instance_attribute = True
142
143
144 class E:
145 """
146 Class doctring.
147
148 :cvar DESCRIBED_IN_CLASS_DOCSTRING: Described in class docstring.
149 :cvar DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING: Described and annotated in class docstring.
150 :vartype DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING: bool
151 :cvar DESCRIBED_IN_BOTH: Described in both.
152 :cvar DESCRIBED_AND_ANNOTATED_IN_BOTH: Described and annotated in both.
153 :vartype DESCRIBED_AND_ANNOTATED_IN_BOTH: bool
154
155 :var described_in_class_and_init_docstring: Described in class and init docstring.
156 :var described_and_annotated_in_class_and_init_docstring: Described and annotated in class and init docstring.
157 :vartype described_and_annotated_in_class_and_init_docstring: bool
158 :var described_everywhere: Described everywhere.
159 :var described_and_annotated_everywhere: Described and annotated everywhere.
160 :vartype described_and_annotated_everywhere: bool
161 """
162
163 IN_CLASS = 0
164 """In class."""
165
166 DESCRIBED_IN_CLASS_DOCSTRING: bool = True
167 DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING = True
168
169 DESCRIBED_IN_BOTH: bool = True
170 """Described in both."""
171
172 DESCRIBED_AND_ANNOTATED_IN_BOTH: bool = True
173 """Described and annotated in both."""
174
175 both_class_and_instance_attribute: Optional[bool] = None
176
177 def __init__(self):
178 """
179 Init doctring.
180
181 :var described_in_class_and_init_docstring: Described in class and init docstring.
182 :var described_and_annotated_in_class_and_init_docstring: Described and annotated in class and init docstring.
183 :vartype described_and_annotated_in_class_and_init_docstring: bool
184 :var described_everywhere: Described everywhere.
185 :var described_and_annotated_everywhere: Described and annotated everywhere.
186 :vartype described_and_annotated_everywhere: bool
187 """
188 self.in_init = True
189 """In init."""
190
191 self.annotated_in_init: bool = True
192 """Annotated in init."""
193
194 self.described_in_class_and_init_docstring: bool = True
195 self.described_and_annotated_in_class_and_init_docstring = True
196
197 self.described_everywhere: bool = True
198 """Described everywhere."""
199
200 self.described_and_annotated_everywhere: bool = True
201 """Described and annotated everywhere."""
202
203 non_attribute: bool = True
204 """Non attribute."""
205
206 non_attribute2 = True
207 """Non attribute 2."""
208
209 if not self.both_class_and_instance_attribute:
210 self.both_class_and_instance_attribute = True
211
212 d = D()
213 d.non_self_attribute = 0
214 """Non self attribute."""
215
216 self.d = d
217 self.d.non_self_attribute2 = 0
218 """Non self attribute 2."""
219
220 c = C()
221 c.non_self_attribute: int = 0
222 """Non self attribute."""
223
224 self.c = c
225 self.c.non_self_attribute2: int = 0
226 """Non self attribute 2."""
227
228
229 if True:
230 IN_IF: bytes = b""
231 """In if."""
232
233 ANNOTATED_IN_IF: str = ""
234 """Annotated in if."""
235 else:
236 IN_ELSE: list = []
237 """In else."""
238
239 try:
240 IN_TRY: int = 1000
241 """In try."""
242 except: # noqa
243 IN_EXCEPT: float = 9000.0
244 """In except."""
245 else:
246 IN_TRY_ELSE: str = "-1"
247 """In try else."""
248 finally:
249 IN_FINALLY: bool = bool(-9000)
250 """In finally."""
251
252
253 class Model(BaseModel):
254 in_pydantic_model: int
255 """In Pydantic model."""
256
257 model_field: Optional[datetime] = None
258 """A model field."""
259
260
261 class MarshmallowSchema(Schema):
262 in_marshmallow_model: int
263 """In Marshmallow model."""
264
265 model_field: fields.Str = fields.Str()
266 """A model field."""
267
268
269 OK, WARNING, CRITICAL, UNKNOWN = 0, 0, 0, 0