From 0c97b8eac7a601fab2903eac7c0439ec021aa2f9 Mon Sep 17 00:00:00 2001 From: Isaac To Date: Tue, 19 Dec 2023 09:51:52 -0800 Subject: [PATCH] Revert marking of `@container` using stringification This solution is kept for now so that context generator can maintain the same behavior --- dandischema/metadata.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/dandischema/metadata.py b/dandischema/metadata.py index d753e5a..072710c 100644 --- a/dandischema/metadata.py +++ b/dandischema/metadata.py @@ -3,17 +3,7 @@ from inspect import isclass import json from pathlib import Path -from typing import ( - Any, - Dict, - Iterable, - Optional, - TypeVar, - Union, - cast, - get_args, - get_origin, -) +from typing import Any, Dict, Iterable, Optional, TypeVar, Union, cast, get_args import jsonschema import pydantic @@ -100,7 +90,10 @@ def generate_context() -> dict: # The annotation without the top-level optional stripped_annotation = strip_top_level_optional(field.annotation) - if get_origin(stripped_annotation) is list: + # Using stringification to detect present of list in annotation is not + # ideal, but it works for now. A better solution should be used in the + # future. + if "list" in str(stripped_annotation).lower(): fields[name]["@container"] = "@set" # Handle the case where the type of the element of a list is