Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nutti committed Jan 10, 2025
1 parent 968a344 commit 6a75dfa
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/fake_bpy_module/transformer/data_type_refiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,19 +727,12 @@ def _get_refined_data_type_splited(
uniq_full_names = self._entry_points_cache["uniq_full_names"]
uniq_module_names = self._entry_points_cache["uniq_module_names"]

# Handle Python typing syntax.
if m := _REGEX_DATA_TYPE_MODIFIER_TYPES.match(dtype_str):
pydoc_to_typing_annotation = {
"Sequence": "collections.abc.Sequence",
"Callable": "collections.abc.Callable",
}

modifier = m.group(1)
if modifier is None:
modifier = ""
modifier = pydoc_to_typing_annotation.get(modifier, modifier)
# [Ex] (Vector, Quaternion, Vector) # noqa: ERA001
if m := _REGEX_DATA_TYPE_START_AND_END_WITH_PARENTHESES.match(
dtype_str):
modifier = "tuple"

elements = split_string_by_comma(m.group(2), False)
elements = split_string_by_comma(m.group(1), False)
elm_dtype_nodes: list[list[DataTypeNode]] = []
for elm in elements:
dtype_nodes = self._get_refined_data_type_internal(
Expand All @@ -763,12 +756,19 @@ def _get_refined_data_type_splited(
append_child(new_dtype_node, nodes.Text(modifier))
return [new_dtype_node]

# [Ex] (Vector, Quaternion, Vector) # noqa: ERA001
if m := _REGEX_DATA_TYPE_START_AND_END_WITH_PARENTHESES.match(
dtype_str):
modifier = "tuple"
# Handle Python typing syntax.
if m := _REGEX_DATA_TYPE_MODIFIER_TYPES.match(dtype_str):
pydoc_to_typing_annotation = {
"Sequence": "collections.abc.Sequence",
"Callable": "collections.abc.Callable",
}

elements = split_string_by_comma(m.group(1), False)
modifier = m.group(1)
if modifier is None:
modifier = ""
modifier = pydoc_to_typing_annotation.get(modifier, modifier)

elements = split_string_by_comma(m.group(2), False)
elm_dtype_nodes: list[list[DataTypeNode]] = []
for elm in elements:
dtype_nodes = self._get_refined_data_type_internal(
Expand Down

0 comments on commit 6a75dfa

Please sign in to comment.