Skip to content

Commit

Permalink
Revert marking of @container using stringification
Browse files Browse the repository at this point in the history
This solution is kept for now so that context generator
can maintain the same behavior
  • Loading branch information
candleindark committed Dec 19, 2023
1 parent 2fcc005 commit 0c97b8e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c97b8e

Please sign in to comment.