Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.

Commit 9dbf8b8

Browse files
authored
fix(parser): don't create enums for union types (#970)
* fix(parser): don't create enum annotations if union type is detected * chore(data): regenerate annotations * style: apply automatic fixes of linters Co-authored-by: lars-reimann <lars-reimann@users.noreply.github.com>
1 parent 97154b0 commit 9dbf8b8

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

package-parser/package_parser/processing/annotations/_generate_enum_annotations.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
EnumPair,
77
ValueAnnotation,
88
)
9-
from package_parser.processing.api.model import API, EnumType, UnionType
9+
from package_parser.processing.api.model import API, EnumType
1010

1111
from ._constants import autogen_author
1212

@@ -33,13 +33,7 @@ def _generate_enum_annotations(api: API, annotations: AnnotationStore) -> None:
3333

3434
pairs = []
3535
full_match = ""
36-
if isinstance(parameter_type, UnionType):
37-
for type_in_union in parameter_type.types:
38-
if isinstance(type_in_union, EnumType):
39-
pairs = _enum_pairs(type_in_union)
40-
full_match = type_in_union.full_match
41-
42-
elif isinstance(parameter_type, EnumType):
36+
if isinstance(parameter_type, EnumType):
4337
pairs = _enum_pairs(parameter_type)
4438
full_match = parameter_type.full_match
4539

package-parser/tests/data/enumAnnotations/annotation_data.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,6 @@
2020
}
2121
]
2222
},
23-
"test/test/some_global_function/enum_parameter_with_union": {
24-
"target": "test/test/some_global_function/enum_parameter_with_union",
25-
"authors": ["$autogen$"],
26-
"reviewers": [],
27-
"comment": "I turned this into an enum because the type in the documentation contained {'auto', 'kd_tree', 'kd-means++'}.",
28-
"enumName": "EnumParameterWithUnion",
29-
"pairs": [
30-
{
31-
"stringValue": "auto",
32-
"instanceName": "AUTO"
33-
},
34-
{
35-
"stringValue": "kd-means++",
36-
"instanceName": "KD_MEANS"
37-
},
38-
{
39-
"stringValue": "kd_tree",
40-
"instanceName": "KD_TREE"
41-
}
42-
]
43-
},
4423
"test/test/some_global_function/issue_760": {
4524
"target": "test/test/some_global_function/issue_760",
4625
"authors": ["$autogen$"],

0 commit comments

Comments
 (0)