def __dir__(self): if PY2: # pragma: py3 no cover base = instance_dir(self) else: # pragma: py2 no cover # noinspection PyUnresolvedReferences base = super().__dir__() keys = sorted(set(base + list(self))) keys = [k for k in keys if is_valid_python_name(k)] return keys