fix bug where datasources with empty sets would generate the wrong response

This commit is contained in:
evilchili 2024-02-17 15:46:23 -08:00
parent 38fd1e9356
commit 4ed084965e
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "random-sets"
version = "0.1.0"
version = "0.1.1"
description = "A small library of helper classes for dealing with random data using weighted distributions"
authors = ["evilchili <evilchili@gmail.com>"]
readme = "README.md"

View File

@ -124,7 +124,7 @@ class DataSource:
# If there is no data for the specified option, stop now.
flattened = [option]
if not self.data[option]:
flattened
return random.choice(flattened) if rand else flattened
if hasattr(self.data[option], 'keys'):
# if the option is a dict, we assume the values are lists; we select a random item