Improve implementation of __getattr__
object does not actually define __getattr__, so the previous
implementation would raise AttributeError implicitly,
which happens to be exactly what we need in this case.
However, raising it explicitly is better understandable.
Found with pytype
@@ -37,9 +37,10 @@ class ColumnStatistics(object):
)
def __getattr__(self, name):
+ # This is called for fields that have not been set previously, default is None
if name in ColumnStatistics._fields:
- return None
- return super().__getattr__(name)
+ return None # noqa: R501 specifying None explicitly is clearer
+ raise AttributeError("can't get attribute " + name)
def __setattr__(self, name, value):
if name in ColumnStatistics._fields:
