An improved Python `hasattr` for Jinja

By figuring out a fix for a security issue in Jinja, I came up with a more robust version of Python's hasattr . One interesting difference between Python and Jinja is that obj.attr (attribute lookup) falls back to obj["attr"] (container lookup) and vice versa. When Jinja is compiled, every occurrence of obj.attr is replaced with env.getattr(obj, attr) behind the scenes. import typing as t class…