From f2c7f61b7d4b419ca0edd3e79463db6c6c60ebea Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Thu, 19 Jan 2017 19:07:12 +0100 Subject: [PATCH] include class attributes in __dir__ This enables tab completion for methods as well as fieldnames. --- capnp/lib/capnp.pyx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index 284bd7c..7397b1e 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -1081,7 +1081,7 @@ cdef class _DynamicStructReader: return self._schema def __dir__(self): - return list(self.schema.fieldnames) + return list(set(self.schema.fieldnames + tuple(dir(self.__class__)))) def __str__(self): return printStructReader(self.thisptr).flatten().cStr() @@ -1413,7 +1413,7 @@ cdef class _DynamicStructBuilder: return self._schema def __dir__(self): - return list(self.schema.fieldnames) + return list(set(self.schema.fieldnames + tuple(dir(self.__class__)))) def __str__(self): return printStructBuilder(self.thisptr).flatten().cStr() @@ -1490,7 +1490,7 @@ cdef class _DynamicStructPipeline: return _StructSchema()._init(self.thisptr.getSchema()) def __dir__(self): - return list(self.schema.fieldnames) + return list(set(self.schema.fieldnames + tuple(dir(self.__class__)))) # def __str__(self): # return printStructReader(self.thisptr).flatten().cStr() @@ -1972,7 +1972,7 @@ cdef class _RemotePromise: return _StructSchema()._init(self.thisptr.getSchema()) def __dir__(self): - return list(self.schema.fieldnames) + return list(set(self.schema.fieldnames + tuple(dir(self.__class__)))) def to_dict(self, verbose=False, ordered=False): return _to_dict(self, verbose, ordered) @@ -2176,7 +2176,7 @@ cdef class _DynamicCapabilityClient: return self._cached_schema def __dir__(self): - return list(self.schema.method_names_inherited) + return list(set(self.schema.method_names_inherited) + tuple(dir(self.__class__))) cdef class _CapabilityClient: cdef C_Capability.Client * thisptr