Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions process/core/io/data_structure_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,26 @@ def get_dicts():
):
var_names_and_descriptions[lastvar.target.id] = ""

# Need to handle new dataclasses slightly differently as variable descriptions
# now are found under the ast.ClassDef node:
for node in module_tree.body:
if isinstance(node, ast.ClassDef):
for node1, node2 in pairwise(node.body):
if isinstance(node1, ast.AnnAssign) and isinstance(node2, ast.Expr):
# if docstring immediately follows the variable declaration, add docstring to descriptions dict
var_names_and_descriptions[node1.target.id] = node2.value.value
if isinstance(node1, ast.AnnAssign) and not isinstance(
node2, ast.Expr
):
# if no docstring for variable, have a blank description
var_names_and_descriptions[node1.target.id] = ""
Comment on lines +489 to +493
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this second condition needed? Surely any situation other than declaration->docstring should have a blank description so this could just be an else

last_var = node.body[-1]
if (
isinstance(last_var, ast.AnnAssign)
and last_var not in var_names_and_descriptions
):
var_names_and_descriptions[last_var.target.id] = ""

dict_module_entry[module_name] = variable_names

output_dict["DICT_MODULE"].update(dict_module_entry)
Expand Down
Loading