code-annotations 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- code_annotations/__init__.py +6 -0
- code_annotations/annotation_errors.py +64 -0
- code_annotations/base.py +647 -0
- code_annotations/cli.py +271 -0
- code_annotations/contrib/README.rst +8 -0
- code_annotations/contrib/config/__init__.py +14 -0
- code_annotations/contrib/config/feature_toggle_annotations.yaml +29 -0
- code_annotations/contrib/config/openedx_events_annotations.yaml +20 -0
- code_annotations/contrib/config/setting_annotations.yaml +13 -0
- code_annotations/contrib/sphinx/extensions/__init__.py +3 -0
- code_annotations/contrib/sphinx/extensions/base.py +53 -0
- code_annotations/contrib/sphinx/extensions/featuretoggles.py +137 -0
- code_annotations/contrib/sphinx/extensions/openedx_events.py +182 -0
- code_annotations/contrib/sphinx/extensions/settings.py +139 -0
- code_annotations/exceptions.py +9 -0
- code_annotations/extensions/__init__.py +3 -0
- code_annotations/extensions/base.py +166 -0
- code_annotations/extensions/javascript.py +20 -0
- code_annotations/extensions/python.py +20 -0
- code_annotations/find_django.py +460 -0
- code_annotations/find_static.py +96 -0
- code_annotations/generate_docs.py +165 -0
- code_annotations/helpers.py +182 -0
- code_annotations/report_templates/html/annotation.tpl +14 -0
- code_annotations/report_templates/html/annotation_data.tpl +8 -0
- code_annotations/report_templates/html/annotation_list.tpl +27 -0
- code_annotations/report_templates/html/base.tpl +92 -0
- code_annotations/report_templates/rst/annotation.tpl +13 -0
- code_annotations/report_templates/rst/annotation_data.tpl +8 -0
- code_annotations/report_templates/rst/annotation_group.tpl +2 -0
- code_annotations/report_templates/rst/annotation_list.tpl +34 -0
- code_annotations/report_templates/rst/base.tpl +41 -0
- code_annotations-3.1.0.dist-info/METADATA +82 -0
- code_annotations-3.1.0.dist-info/RECORD +39 -0
- code_annotations-3.1.0.dist-info/WHEEL +5 -0
- code_annotations-3.1.0.dist-info/entry_points.txt +6 -0
- code_annotations-3.1.0.dist-info/licenses/LICENSE.txt +202 -0
- code_annotations-3.1.0.dist-info/licenses/NOTICE.txt +13 -0
- code_annotations-3.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""
|
|
2
|
+
List possible annotation error types.
|
|
3
|
+
"""
|
|
4
|
+
from collections import namedtuple
|
|
5
|
+
|
|
6
|
+
AnnotationErrorType = namedtuple(
|
|
7
|
+
"AnnotationError", ["message", "symbol", "description"]
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
# The TYPES list should contain all AnnotationErrorType instances. This list can then be parsed by others, for instance
|
|
11
|
+
# to expose errors to pylint.
|
|
12
|
+
TYPES = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def add_error_type(message, symbol, description):
|
|
16
|
+
"""
|
|
17
|
+
Create an AnnotationErrorType instance and add it to TYPES.
|
|
18
|
+
"""
|
|
19
|
+
error_type = AnnotationErrorType(
|
|
20
|
+
message,
|
|
21
|
+
symbol,
|
|
22
|
+
description,
|
|
23
|
+
)
|
|
24
|
+
TYPES.append(error_type)
|
|
25
|
+
if len(TYPES) > 10:
|
|
26
|
+
# if more than 10 items are created here, numerical IDs generated by edx-lint will overlap with other warning
|
|
27
|
+
# IDs.
|
|
28
|
+
raise ValueError("TYPES may not contain more than 10 items")
|
|
29
|
+
return error_type
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# It is important to preserve the insertion order of these error types in the TYPES list, as edx-lint uses the error
|
|
33
|
+
# type indices to generate numerical pylint IDs. If the insertion order is changed, the pylint IDs will change too,
|
|
34
|
+
# which might cause incompatibilities down the road. Thus, new items should be added at the end.
|
|
35
|
+
InvalidChoice = add_error_type(
|
|
36
|
+
'"%s" is not a valid choice for "%s". Expected one of %s.',
|
|
37
|
+
"annotation-invalid-choice",
|
|
38
|
+
"Emitted when the value of a choice field is not one of the valid choices",
|
|
39
|
+
)
|
|
40
|
+
DuplicateChoiceValue = add_error_type(
|
|
41
|
+
'"%s" is already present in this annotation.',
|
|
42
|
+
"annotation-duplicate-choice-value",
|
|
43
|
+
"Emitted when duplicate values are found in a choice field",
|
|
44
|
+
)
|
|
45
|
+
MissingChoiceValue = add_error_type(
|
|
46
|
+
'no value found for "%s". Expected one of %s.',
|
|
47
|
+
"annotation-missing-choice-value",
|
|
48
|
+
"Emitted when a choice field does not have any value",
|
|
49
|
+
)
|
|
50
|
+
InvalidToken = add_error_type(
|
|
51
|
+
"'%s' token does not belong to group '%s'. Expected one of: %s",
|
|
52
|
+
"annotation-invalid-token",
|
|
53
|
+
"Emitted when a token is found in a group for which it is not valid",
|
|
54
|
+
)
|
|
55
|
+
DuplicateToken = add_error_type(
|
|
56
|
+
"found duplicate token '%s'",
|
|
57
|
+
"annotation-duplicate-token",
|
|
58
|
+
"Emitted when a token is found twice in a group",
|
|
59
|
+
)
|
|
60
|
+
MissingToken = add_error_type(
|
|
61
|
+
"missing non-optional annotation: '%s'",
|
|
62
|
+
"annotation-missing-token",
|
|
63
|
+
"Emitted when a required token is missing from a group",
|
|
64
|
+
)
|