Use random type when field is nullable
Closed this issue · 5 comments
andrewshawcare commented
In the following line:
Line 78 in 3db7519
A TypeError
is raised when the item type represents more than one type (excluding null
). I'm not sure why.
Can this method just return a random type from the list (including null)?
So:
import random
...
def __is_field_nullable(self, schema: Dict[str, Any]) -> Tuple[str, bool]:
item_type = schema.get("type")
if isinstance(item_type, list):
if "null" in item_type:
return random.choice(item_type), True
return item_type, False
ghandic commented
Absolutely! Looks like an artifact of building too specific to a spec I had. Please raise a PR
andrewshawcare commented
ghandic commented
Could you run the test locally and get it passing? Looks like theres further changes required. I'll revert the merge until then
andrewshawcare commented
My apologies, the PR above passes tests locally (and in the pipeline).
andrewshawcare commented
Thanks for merging. When do you think you'll be making a new release? Thanks!