jaraco / wolframalpha

MIT License
148 stars 26 forks source link

ValueError when attempting to access Pod.subpods #26

Closed Harmon758 closed 3 years ago

Harmon758 commented 3 years ago

25 is an issue with v4.1.0 rather than with the API.

https://github.com/jaraco/wolframalpha/commit/77bac9ad5bb730b9146a4cc09d1595c54fb6c678 changed https://github.com/jaraco/wolframalpha/blob/34f89546b2ae11766aebedad8560388e55421cf8/wolframalpha/__init__.py#L80 to use more_itertools.always_iterable rather than jaraco.itertools.always_iterable.

By default, jaraco.itertools.always_iterable treats a dictionary as a singleton, whereas more_itertools.always_iterable iterates over the dictionary's keys. This causes accessing Pod.subpods to error with ValueError: dictionary update sequence element #0 has length 1; 2 is required now, as when a subpod dictionary is passed to more_itertools.always_iterable, it will iterate over each of the keys, and when Subpod is initialized, it will attempt to cast each of those keys, rather than the entire subpod dictionary, to a dict.

jaraco commented 3 years ago

It's so frustrating that although I contributed always_iterable to more_itertools, the implementation had to be tweaked to be less useful in situations like these.