]> Devi Nivas Git - chevron.git/commit
Allow field access for namedtuple in Python 3
authorThomas Hebb <tommyhebb@gmail.com>
Sat, 23 May 2020 03:24:22 +0000 (23:24 -0400)
committerThomas Hebb <tommyhebb@gmail.com>
Sat, 23 May 2020 03:35:27 +0000 (23:35 -0400)
commit2a9dcdeb8fefae44de19a94d09bffb44eadd9e13
tree293ed57afe7d601df813517d113cbabe905e84a7
parent78f1a384eddef16906732d8db66deea6d37049b7
Allow field access for namedtuple in Python 3

`namedtuple` in Python 3 does not provide a `__dict__` attribute. See
https://bugs.python.org/issue24931 for rationale why. As such, if we
want to render keys in `namedtuple`s, we need to use its [`_asdict`][1]
method.

[1]: https://docs.python.org/3/library/collections.html#collections.somenamedtuple._asdict
chevron/renderer.py
test_spec.py