Coverage for tests/fixtures/parsing/restructured_text/attributes.py: 53.24%
131 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-09 17:28 +0100
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-09 17:28 +0100
1"""
2Module docstring.
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"""
12from datetime import datetime
13from typing import Optional, Tuple
15from marshmallow import Schema, fields
16from pydantic import BaseModel
18NO_DOC_NO_TYPE = 0
20NO_TYPE = 1
21"""No type."""
23NO_DOC_NO_VALUE: int
25NO_VALUE: str
26"""No value."""
28NO_DOC: int = 2
30FULL: int = 3
31"""Full."""
33DESCRIBED_IN_MODULE_DOCSTRING: bool = True
34DESCRIBED_AND_ANNOTATED_IN_MODULE_DOCSTRING = True
36DESCRIBED_IN_BOTH: bool = True
37"""Described in both."""
39DESCRIBED_AND_ANNOTATED_IN_BOTH: bool = True
40"""Described and annotated in both."""
42COMPLEX_TYPE: Optional[Tuple[int, str]] = None
43"""Complex type."""
46ATTRIBUTE_C1: "C"
47"""Forward reference for type."""
50ATTRIBUTE_C2: Optional["C"] = None
51"""Optional forward reference for type."""
54class C:
55 """
56 Class doctring.
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
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 """
73 IN_CLASS = 0
74 """In class."""
76 DESCRIBED_IN_CLASS_DOCSTRING: bool = True
77 DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING = True
79 DESCRIBED_IN_BOTH: bool = True
80 """Described in both."""
82 DESCRIBED_AND_ANNOTATED_IN_BOTH: bool = True
83 """Described and annotated in both."""
85 both_class_and_instance_attribute: Optional[bool] = None
87 def __init__(self):
88 self.in_init = True
89 """In init."""
91 self.annotated_in_init: bool = True
92 """Annotated in init."""
94 self.described_in_class_docstring: bool = True
95 self.described_and_annotated_in_class_docstring = True
97 self.described_in_both: bool = True
98 """Described in both."""
100 self.described_and_annotated_in_both: bool = True
101 """Described and annotated in both."""
103 non_attribute: bool = True
104 """Non attribute."""
106 if not self.both_class_and_instance_attribute:
107 self.both_class_and_instance_attribute = True
110class D:
111 def __init__(self):
112 """
113 Init doctring.
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."""
125 self.annotated_in_init: bool = True
126 """Annotated in init."""
128 self.described_in_class_docstring: bool = True
129 self.described_and_annotated_in_class_docstring = True
131 self.described_in_both: bool = True
132 """Described in both."""
134 self.described_and_annotated_in_both: bool = True
135 """Described and annotated in both."""
137 non_attribute: bool = True
138 """Non attribute."""
140 if not self.both_class_and_instance_attribute:
141 self.both_class_and_instance_attribute = True
144class E:
145 """
146 Class doctring.
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
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 """
163 IN_CLASS = 0
164 """In class."""
166 DESCRIBED_IN_CLASS_DOCSTRING: bool = True
167 DESCRIBED_AND_ANNOTATED_IN_CLASS_DOCSTRING = True
169 DESCRIBED_IN_BOTH: bool = True
170 """Described in both."""
172 DESCRIBED_AND_ANNOTATED_IN_BOTH: bool = True
173 """Described and annotated in both."""
175 both_class_and_instance_attribute: Optional[bool] = None
177 def __init__(self):
178 """
179 Init doctring.
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."""
191 self.annotated_in_init: bool = True
192 """Annotated in init."""
194 self.described_in_class_and_init_docstring: bool = True
195 self.described_and_annotated_in_class_and_init_docstring = True
197 self.described_everywhere: bool = True
198 """Described everywhere."""
200 self.described_and_annotated_everywhere: bool = True
201 """Described and annotated everywhere."""
203 non_attribute: bool = True
204 """Non attribute."""
206 non_attribute2 = True
207 """Non attribute 2."""
209 if not self.both_class_and_instance_attribute:
210 self.both_class_and_instance_attribute = True
212 d = D()
213 d.non_self_attribute = 0
214 """Non self attribute."""
216 self.d = d
217 self.d.non_self_attribute2 = 0
218 """Non self attribute 2."""
220 c = C()
221 c.non_self_attribute: int = 0
222 """Non self attribute."""
224 self.c = c
225 self.c.non_self_attribute2: int = 0
226 """Non self attribute 2."""
229if True:
230 IN_IF: bytes = b""
231 """In if."""
233 ANNOTATED_IN_IF: str = ""
234 """Annotated in if."""
235else:
236 IN_ELSE: list = []
237 """In else."""
239try:
240 IN_TRY: int = 1000
241 """In try."""
242except: # noqa
243 IN_EXCEPT: float = 9000.0
244 """In except."""
245else:
246 IN_TRY_ELSE: str = "-1"
247 """In try else."""
248finally:
249 IN_FINALLY: bool = bool(-9000)
250 """In finally."""
253class Model(BaseModel):
254 in_pydantic_model: int
255 """In Pydantic model."""
257 model_field: Optional[datetime] = None
258 """A model field."""
261class MarshmallowSchema(Schema):
262 in_marshmallow_model: int
263 """In Marshmallow model."""
265 model_field: fields.Str = fields.Str()
266 """A model field."""
269OK, WARNING, CRITICAL, UNKNOWN = 0, 0, 0, 0