Merge pull request #255 from jayvdb/delint

Remove many pycodestyle warnings
This commit is contained in:
Jacob Alexander
2021-05-03 04:07:40 -07:00
committed by GitHub
10 changed files with 557 additions and 231 deletions

View File

@@ -32,8 +32,8 @@ jobs:
- name: Lint with flake8 - name: Lint with flake8
run: | run: |
pip install flake8 pip install flake8
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude benchmark flake8 . --filename '*.py,*.pyx,*.pxd' --count --max-complexity=10 --max-line-length=120 --ignore=E211,E225,E226,E227,E231,E251,E261,E262,E265,E402,E722,E999 --show-source --statistics --exclude benchmark,build,capnp/templates/module.pyx
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark flake8 . --count --max-complexity=10 --max-line-length=120 --show-source --statistics --exclude benchmark,build
- name: Packaging - name: Packaging
run: | run: |
python setup.py bdist_wheel python setup.py bdist_wheel

View File

@@ -1,4 +1,9 @@
from capnp.includes.capnp_cpp cimport Maybe, ReaderOptions, DynamicStruct, Request, Response, PyPromise, VoidPromise, PyPromiseArray, RemotePromise, DynamicCapability, InterfaceSchema, EnumSchema, StructSchema, DynamicValue, Capability, RpcSystem, MessageBuilder, MessageReader, TwoPartyVatNetwork, AnyPointer, DynamicStruct_Builder, WaitScope, AsyncIoContext, StringPtr, TaskSet, Timer, AsyncIoStreamReadHelper from capnp.includes.capnp_cpp cimport (
Maybe, ReaderOptions, DynamicStruct, Request, Response, PyPromise, VoidPromise, PyPromiseArray,
RemotePromise, DynamicCapability, InterfaceSchema, EnumSchema, StructSchema, DynamicValue,
Capability, RpcSystem, MessageBuilder, MessageReader, TwoPartyVatNetwork, AnyPointer,
DynamicStruct_Builder, WaitScope, AsyncIoContext, StringPtr, TaskSet, Timer, AsyncIoStreamReadHelper,
)
from capnp.includes.schema_cpp cimport ByteArray from capnp.includes.schema_cpp cimport ByteArray

View File

@@ -4,8 +4,12 @@ cdef extern from "capnp/helpers/checkCompiler.h":
pass pass
from libcpp cimport bool from libcpp cimport bool
from capnp.helpers.non_circular cimport PythonInterfaceDynamicImpl, reraise_kj_exception, PyRefCounter, PyEventPort, ErrorHandler from capnp.helpers.non_circular cimport (
from capnp.includes.schema_cpp cimport Node, Data, StructNode, EnumNode, InterfaceNode, MessageBuilder, MessageReader, ReaderOptions PythonInterfaceDynamicImpl, reraise_kj_exception, PyRefCounter, PyEventPort, ErrorHandler,
)
from capnp.includes.schema_cpp cimport (
Node, Data, StructNode, EnumNode, InterfaceNode, MessageBuilder, MessageReader, ReaderOptions,
)
from capnp.includes.types cimport * from capnp.includes.types cimport *
cdef extern from "capnp/common.h" namespace " ::capnp": cdef extern from "capnp/common.h" namespace " ::capnp":
@@ -46,8 +50,10 @@ cdef extern from "kj/memory.h" namespace " ::kj":
cdef cppclass Own[T]: cdef cppclass Own[T]:
T& operator*() T& operator*()
T* get() T* get()
Own[TwoPartyVatNetwork] makeTwoPartyVatNetwork" ::kj::heap< ::capnp::TwoPartyVatNetwork>"(AsyncIoStream& stream, Side, ReaderOptions) Own[TwoPartyVatNetwork] makeTwoPartyVatNetwork" ::kj::heap< ::capnp::TwoPartyVatNetwork>"(
Own[PromiseFulfillerPair] copyPromiseFulfillerPair" ::kj::heap< ::kj::PromiseFulfillerPair<void> >"(PromiseFulfillerPair&) AsyncIoStream& stream, Side, ReaderOptions)
Own[PromiseFulfillerPair] copyPromiseFulfillerPair" ::kj::heap< ::kj::PromiseFulfillerPair<void> >"(
PromiseFulfillerPair&)
Own[PyRefCounter] makePyRefCounter" ::kj::heap< PyRefCounter >"(PyObject *) Own[PyRefCounter] makePyRefCounter" ::kj::heap< PyRefCounter >"(PyObject *)
cdef extern from "kj/async.h" namespace " ::kj": cdef extern from "kj/async.h" namespace " ::kj":
@@ -309,7 +315,8 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
DynamicValueForward.Pipeline get(char *) DynamicValueForward.Pipeline get(char *)
StructSchema getSchema() StructSchema getSchema()
cdef cppclass DynamicStruct_Builder" ::capnp::DynamicStruct::Builder": # Need to flatten this class out, since nested C++ classes cause havoc with cython fused types cdef cppclass DynamicStruct_Builder" ::capnp::DynamicStruct::Builder":
# Need to flatten this class out, since nested C++ classes cause havoc with cython fused types
DynamicStruct_Builder() DynamicStruct_Builder()
DynamicStruct_Builder(DynamicStruct_Builder &) DynamicStruct_Builder(DynamicStruct_Builder &)
DynamicValueForward.Builder get(char *) except +reraise_kj_exception DynamicValueForward.Builder get(char *) except +reraise_kj_exception
@@ -344,7 +351,8 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
cdef extern from "capnp/capability.h" namespace " ::capnp": cdef extern from "capnp/capability.h" namespace " ::capnp":
cdef cppclass Response" ::capnp::Response< ::capnp::DynamicStruct>"(DynamicStruct.Reader): cdef cppclass Response" ::capnp::Response< ::capnp::DynamicStruct>"(DynamicStruct.Reader):
Response(Response) Response(Response)
cdef cppclass RemotePromise" ::capnp::RemotePromise< ::capnp::DynamicStruct>"(Promise[Response], DynamicStruct.Pipeline): cdef cppclass RemotePromise" ::capnp::RemotePromise< ::capnp::DynamicStruct>"(
Promise[Response], DynamicStruct.Pipeline):
RemotePromise(RemotePromise) RemotePromise(RemotePromise)
cdef cppclass Capability: cdef cppclass Capability:
cppclass Client: cppclass Client:
@@ -404,20 +412,23 @@ cdef extern from "capnp/any.h" namespace " ::capnp":
cdef cppclass AnyPointer: cdef cppclass AnyPointer:
cppclass Reader: cppclass Reader:
DynamicStruct.Reader getAs"getAs< ::capnp::DynamicStruct>"(StructSchema) except +reraise_kj_exception DynamicStruct.Reader getAs"getAs< ::capnp::DynamicStruct>"(StructSchema) except +reraise_kj_exception
DynamicCapability.Client getAsCapability"getAs< ::capnp::DynamicCapability>"(InterfaceSchema) except +reraise_kj_exception DynamicCapability.Client getAsCapability"getAs< ::capnp::DynamicCapability>"(
InterfaceSchema) except +reraise_kj_exception
DynamicList.Reader getAsList"getAs< ::capnp::DynamicList>"(ListSchema) except +reraise_kj_exception DynamicList.Reader getAsList"getAs< ::capnp::DynamicList>"(ListSchema) except +reraise_kj_exception
StringPtr getAsText"getAs< ::capnp::Text>"() except +reraise_kj_exception StringPtr getAsText"getAs< ::capnp::Text>"() except +reraise_kj_exception
cppclass Builder: cppclass Builder:
Builder(Builder) Builder(Builder)
DynamicStruct_Builder getAs"getAs< ::capnp::DynamicStruct>"(StructSchema) except +reraise_kj_exception DynamicStruct_Builder getAs"getAs< ::capnp::DynamicStruct>"(StructSchema) except +reraise_kj_exception
DynamicCapability.Client getAsCapability"getAs< ::capnp::DynamicCapability>"(InterfaceSchema) except +reraise_kj_exception DynamicCapability.Client getAsCapability"getAs< ::capnp::DynamicCapability>"(
InterfaceSchema) except +reraise_kj_exception
DynamicList.Builder getAsList"getAs< ::capnp::DynamicList>"(ListSchema) except +reraise_kj_exception DynamicList.Builder getAsList"getAs< ::capnp::DynamicList>"(ListSchema) except +reraise_kj_exception
StringPtr getAsText"getAs< ::capnp::Text>"() except +reraise_kj_exception StringPtr getAsText"getAs< ::capnp::Text>"() except +reraise_kj_exception
void setAsStruct"setAs< ::capnp::DynamicStruct>"(DynamicStruct.Reader&) except +reraise_kj_exception void setAsStruct"setAs< ::capnp::DynamicStruct>"(DynamicStruct.Reader&) except +reraise_kj_exception
void setAsText"setAs< ::capnp::Text>"(char*) except +reraise_kj_exception void setAsText"setAs< ::capnp::Text>"(char*) except +reraise_kj_exception
AnyPointer.Reader asReader() except +reraise_kj_exception AnyPointer.Reader asReader() except +reraise_kj_exception
void set(AnyPointer.Reader) except +reraise_kj_exception void set(AnyPointer.Reader) except +reraise_kj_exception
DynamicStruct_Builder initAsStruct"initAs< ::capnp::DynamicStruct>"(StructSchema) except +reraise_kj_exception DynamicStruct_Builder initAsStruct"initAs< ::capnp::DynamicStruct>"(
StructSchema) except +reraise_kj_exception
DynamicList.Builder initAsList"initAs< ::capnp::DynamicList>"(ListSchema, uint) except +reraise_kj_exception DynamicList.Builder initAsList"initAs< ::capnp::DynamicList>"(ListSchema, uint) except +reraise_kj_exception

View File

@@ -60,7 +60,7 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
uint size() uint size()
cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema": cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
enum : enum:
_ElementSize_inlineComposite " ::capnp::schema::ElementSize::INLINE_COMPOSITE" _ElementSize_inlineComposite " ::capnp::schema::ElementSize::INLINE_COMPOSITE"
_ElementSize_eightBytes " ::capnp::schema::ElementSize::EIGHT_BYTES" _ElementSize_eightBytes " ::capnp::schema::ElementSize::EIGHT_BYTES"
_ElementSize_pointer " ::capnp::schema::ElementSize::POINTER" _ElementSize_pointer " ::capnp::schema::ElementSize::POINTER"
@@ -133,7 +133,6 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
cdef cppclass Annotation cdef cppclass Annotation
cdef cppclass CodeGeneratorRequest: cdef cppclass CodeGeneratorRequest:
cppclass Reader: cppclass Reader:
List[CodeGeneratorRequest.Node].Reader getNodes() List[CodeGeneratorRequest.Node].Reader getNodes()
@@ -144,17 +143,15 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
List[CodeGeneratorRequest.Node].Builder initNodes(int) List[CodeGeneratorRequest.Node].Builder initNodes(int)
List[UInt64].Builder getRequestedFiles() List[UInt64].Builder getRequestedFiles()
List[UInt64].Builder initRequestedFiles(int) List[UInt64].Builder initRequestedFiles(int)
cdef cppclass InterfaceNode: cdef cppclass InterfaceNode:
cppclass Method cppclass Method
cppclass Method: cppclass Method:
cppclass Param cppclass Param
cppclass Param: cppclass Param:
cppclass Reader: cppclass Reader:
Value getDefaultValue() Value getDefaultValue()
@@ -171,6 +168,7 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setName(Text) void setName(Text)
List[InterfaceNode.Method.Param.Annotation].Builder getAnnotations() List[InterfaceNode.Method.Param.Annotation].Builder getAnnotations()
List[InterfaceNode.Method.Param.Annotation].Builder initAnnotations(int) List[InterfaceNode.Method.Param.Annotation].Builder initAnnotations(int)
cppclass Reader: cppclass Reader:
UInt16 getCodeOrder() UInt16 getCodeOrder()
@@ -179,6 +177,7 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
UInt16 getRequiredParamCount() UInt16 getRequiredParamCount()
Type getReturnType() Type getReturnType()
List[InterfaceNode.Method.Annotation].Reader getAnnotations() List[InterfaceNode.Method.Annotation].Reader getAnnotations()
cppclass Builder: cppclass Builder:
UInt16 getCodeOrder() UInt16 getCodeOrder()
@@ -193,20 +192,21 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setReturnType(Type) void setReturnType(Type)
List[InterfaceNode.Method.Annotation].Builder getAnnotations() List[InterfaceNode.Method.Annotation].Builder getAnnotations()
List[InterfaceNode.Method.Annotation].Builder initAnnotations(int) List[InterfaceNode.Method.Annotation].Builder initAnnotations(int)
cppclass Reader: cppclass Reader:
List[InterfaceNode.InterfaceNode.Method].Reader getMethods() List[InterfaceNode.InterfaceNode.Method].Reader getMethods()
cppclass Builder: cppclass Builder:
List[InterfaceNode.InterfaceNode.Method].Builder getMethods() List[InterfaceNode.InterfaceNode.Method].Builder getMethods()
List[InterfaceNode.InterfaceNode.Method].Builder initMethods(int) List[InterfaceNode.InterfaceNode.Method].Builder initMethods(int)
cdef cppclass Value: cdef cppclass Value:
cppclass Body cppclass Body
cppclass Body: cppclass Body:
cppclass Reader: cppclass Reader:
int which() int which()
UInt32 getUint32Value() UInt32 getUint32Value()
@@ -228,6 +228,7 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
Text.Reader getTextValue() Text.Reader getTextValue()
UInt64 getUint64Value() UInt64 getUint64Value()
Object getObjectValue() Object getObjectValue()
cppclass Builder: cppclass Builder:
int which() int which()
UInt32 getUint32Value() UInt32 getUint32Value()
@@ -268,33 +269,35 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setUint64Value(UInt64) void setUint64Value(UInt64)
Object getObjectValue() Object getObjectValue()
void setObjectValue(Object) void setObjectValue(Object)
cppclass Reader: cppclass Reader:
Value.Body getBody() Value.Body getBody()
cppclass Builder: cppclass Builder:
Value.Body getBody() Value.Body getBody()
void setBody(Value.Body) void setBody(Value.Body)
cdef cppclass ConstNode:
cdef cppclass ConstNode:
cppclass Reader: cppclass Reader:
Type getType() Type getType()
Value getValue() Value getValue()
cppclass Builder: cppclass Builder:
Type getType() Type getType()
void setType(Type) void setType(Type)
Value getValue() Value getValue()
void setValue(Value) void setValue(Value)
cdef cppclass Type: cdef cppclass Type:
cppclass Body cppclass Body
cppclass Body: cppclass Body:
cppclass Reader: cppclass Reader:
int which() int which()
Void getBoolType() Void getBoolType()
@@ -316,6 +319,7 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
Void getUint64Type() Void getUint64Type()
Void getTextType() Void getTextType()
Void getInt16Type() Void getInt16Type()
cppclass Builder: cppclass Builder:
int which() int which()
Void getBoolType() Void getBoolType()
@@ -356,45 +360,48 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setTextType(Void) void setTextType(Void)
Void getInt16Type() Void getInt16Type()
void setInt16Type(Void) void setInt16Type(Void)
cppclass Reader: cppclass Reader:
Type.Body getBody() Type.Body getBody()
cppclass Builder: cppclass Builder:
Type.Body getBody() Type.Body getBody()
void setBody(Type.Body) void setBody(Type.Body)
cdef cppclass FileNode: cdef cppclass FileNode:
cppclass Import cppclass Import
cppclass Import: cppclass Import:
cppclass Reader: cppclass Reader:
UInt64 getId() UInt64 getId()
Text.Reader getName() Text.Reader getName()
cppclass Builder: cppclass Builder:
UInt64 getId() UInt64 getId()
void setId(UInt64) void setId(UInt64)
Text.Builder getName() Text.Builder getName()
void setName(Text) void setName(Text)
cppclass Reader: cppclass Reader:
List[FileNode.FileNode.Import].Reader getImports() List[FileNode.FileNode.Import].Reader getImports()
cppclass Builder: cppclass Builder:
List[FileNode.FileNode.Import].Builder getImports() List[FileNode.FileNode.Import].Builder getImports()
List[FileNode.FileNode.Import].Builder initImports(int) List[FileNode.FileNode.Import].Builder initImports(int)
cdef cppclass Node: cdef cppclass Node:
cppclass Body cppclass Body
cppclass NestedNode cppclass NestedNode
cppclass Body: cppclass Body:
cppclass Reader: cppclass Reader:
int which() int which()
AnnotationNode getAnnotationNode() AnnotationNode getAnnotationNode()
@@ -417,8 +424,8 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setConstNode(ConstNode) void setConstNode(ConstNode)
FileNode getFileNode() FileNode getFileNode()
void setFileNode(FileNode) void setFileNode(FileNode)
cppclass NestedNode:
cppclass NestedNode:
cppclass Reader: cppclass Reader:
@@ -444,6 +451,7 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
bint isInterface() bint isInterface()
bint isConst() bint isConst()
bint isAnnotation() bint isAnnotation()
cppclass Builder: cppclass Builder:
Node.Body getBody() Node.Body getBody()
@@ -464,8 +472,8 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
bint isInterface() bint isInterface()
bint isConst() bint isConst()
bint isAnnotation() bint isAnnotation()
cdef cppclass AnnotationNode:
cdef cppclass AnnotationNode:
cppclass Reader: cppclass Reader:
@@ -481,6 +489,7 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
Bool getTargetsEnum() Bool getTargetsEnum()
Bool getTargetsInterface() Bool getTargetsInterface()
Bool getTargetsMethod() Bool getTargetsMethod()
cppclass Builder: cppclass Builder:
Bool getTargetsField() Bool getTargetsField()
@@ -507,18 +516,18 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setTargetsInterface(Bool) void setTargetsInterface(Bool)
Bool getTargetsMethod() Bool getTargetsMethod()
void setTargetsMethod(Bool) void setTargetsMethod(Bool)
cdef cppclass EnumNode: cdef cppclass EnumNode:
cppclass Enumerant cppclass Enumerant
cppclass Enumerant: cppclass Enumerant:
cppclass Reader: cppclass Reader:
UInt16 getCodeOrder() UInt16 getCodeOrder()
Text.Reader getName() Text.Reader getName()
List[EnumNode.Enumerant.Annotation].Reader getAnnotations() List[EnumNode.Enumerant.Annotation].Reader getAnnotations()
cppclass Builder: cppclass Builder:
UInt16 getCodeOrder() UInt16 getCodeOrder()
@@ -527,22 +536,23 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setName(Text) void setName(Text)
List[EnumNode.Enumerant.Annotation].Builder getAnnotations() List[EnumNode.Enumerant.Annotation].Builder getAnnotations()
List[EnumNode.Enumerant.Annotation].Builder initAnnotations(int) List[EnumNode.Enumerant.Annotation].Builder initAnnotations(int)
cppclass Reader: cppclass Reader:
List[EnumNode.EnumNode.Enumerant].Reader getEnumerants() List[EnumNode.EnumNode.Enumerant].Reader getEnumerants()
cppclass Builder: cppclass Builder:
List[EnumNode.EnumNode.Enumerant].Builder getEnumerants() List[EnumNode.EnumNode.Enumerant].Builder getEnumerants()
List[EnumNode.EnumNode.Enumerant].Builder initEnumerants(int) List[EnumNode.EnumNode.Enumerant].Builder initEnumerants(int)
cdef cppclass StructNode: cdef cppclass StructNode:
cppclass Union cppclass Union
cppclass Member cppclass Member
cppclass Field cppclass Field
cppclass Union: cppclass Union:
cppclass Reader: cppclass Reader:
UInt32 getDiscriminantOffset() UInt32 getDiscriminantOffset()
@@ -556,10 +566,8 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
cppclass Member: cppclass Member:
cppclass Body cppclass Body
cppclass Body: cppclass Body:
cppclass Reader: cppclass Reader:
int which() int which()
Field getFieldMember() Field getFieldMember()
@@ -589,8 +597,8 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setName(Text) void setName(Text)
List[StructNode.Member.Annotation].Builder getAnnotations() List[StructNode.Member.Annotation].Builder getAnnotations()
List[StructNode.Member.Annotation].Builder initAnnotations(int) List[StructNode.Member.Annotation].Builder initAnnotations(int)
cppclass Field:
cppclass Field:
cppclass Reader: cppclass Reader:
@@ -620,7 +628,6 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
void setPointerSectionSize(UInt16) void setPointerSectionSize(UInt16)
cdef cppclass Annotation: cdef cppclass Annotation:
cppclass Reader: cppclass Reader:
UInt64 getId() UInt64 getId()

View File

@@ -2,7 +2,18 @@
from capnp.includes cimport capnp_cpp as capnp from capnp.includes cimport capnp_cpp as capnp
from capnp.includes cimport schema_cpp from capnp.includes cimport schema_cpp
from capnp.includes.capnp_cpp cimport Schema as C_Schema, StructSchema as C_StructSchema, InterfaceSchema as C_InterfaceSchema, EnumSchema as C_EnumSchema, ListSchema as C_ListSchema, DynamicStruct as C_DynamicStruct, DynamicValue as C_DynamicValue, Type as C_Type, DynamicList as C_DynamicList, SchemaParser as C_SchemaParser, ParsedSchema as C_ParsedSchema, VOID, ArrayPtr, StringPtr, String, StringTree, DynamicOrphan as C_DynamicOrphan, AnyPointer as C_DynamicObject, DynamicCapability as C_DynamicCapability, Request, Response, RemotePromise, Promise, CallContext, RpcSystem, makeRpcServerBootstrap, makeRpcClient, Capability as C_Capability, TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own, makeTwoPartyVatNetwork, PromiseFulfillerPair as C_PromiseFulfillerPair, copyPromiseFulfillerPair, newPromiseAndFulfiller, PyArray, DynamicStruct_Builder, TwoWayPipe from capnp.includes.capnp_cpp cimport (
Schema as C_Schema, StructSchema as C_StructSchema, InterfaceSchema as C_InterfaceSchema,
EnumSchema as C_EnumSchema, ListSchema as C_ListSchema, DynamicStruct as C_DynamicStruct,
DynamicValue as C_DynamicValue, Type as C_Type, DynamicList as C_DynamicList,
SchemaParser as C_SchemaParser, ParsedSchema as C_ParsedSchema, VOID, ArrayPtr, StringPtr,
String, StringTree, DynamicOrphan as C_DynamicOrphan, AnyPointer as C_DynamicObject,
DynamicCapability as C_DynamicCapability, Request, Response, RemotePromise, Promise,
CallContext, RpcSystem, makeRpcServerBootstrap, makeRpcClient, Capability as C_Capability,
TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own, makeTwoPartyVatNetwork,
PromiseFulfillerPair as C_PromiseFulfillerPair, copyPromiseFulfillerPair, newPromiseAndFulfiller,
PyArray, DynamicStruct_Builder, TwoWayPipe,
)
from capnp.includes.schema_cpp cimport Node as C_Node, EnumNode as C_EnumNode from capnp.includes.schema_cpp cimport Node as C_Node, EnumNode as C_EnumNode
from capnp.includes.types cimport * from capnp.includes.types cimport *
from capnp.helpers.non_circular cimport reraise_kj_exception from capnp.helpers.non_circular cimport reraise_kj_exception
@@ -149,7 +160,8 @@ cdef _setDynamicFieldStatic(DynamicStruct_Builder thisptr, field, value, parent)
cdef api object wrap_dynamic_struct_reader(Response & r) with gil cdef api object wrap_dynamic_struct_reader(Response & r) with gil
cdef api PyObject * wrap_remote_call(PyObject * func, Response & r) except * with gil cdef api PyObject * wrap_remote_call(PyObject * func, Response & r) except * with gil
cdef api Promise[void] * call_server_method(PyObject * _server, char * _method_name, CallContext & _context) except * with gil cdef api Promise[void] * call_server_method(
PyObject * _server, char * _method_name, CallContext & _context) except * with gil
cdef api convert_array_pyobject(PyArray & arr) with gil cdef api convert_array_pyobject(PyArray & arr) with gil
cdef api Promise[PyObject*] * extract_promise(object obj) with gil cdef api Promise[PyObject*] * extract_promise(object obj) with gil
cdef api RemotePromise * extract_remote_promise(object obj) with gil cdef api RemotePromise * extract_remote_promise(object obj) with gil

File diff suppressed because it is too large Load Diff

View File

@@ -33,14 +33,13 @@ def write_version_py(filename=None):
Generate pycapnp version Generate pycapnp version
''' '''
cnt = """\ cnt = """\
from .lib.capnp import _CAPNP_VERSION_MAJOR as LIBCAPNP_VERSION_MAJOR # noqa: F401
from .lib.capnp import _CAPNP_VERSION_MINOR as LIBCAPNP_VERSION_MINOR # noqa: F401
from .lib.capnp import _CAPNP_VERSION_MICRO as LIBCAPNP_VERSION_MICRO # noqa: F401
from .lib.capnp import _CAPNP_VERSION as LIBCAPNP_VERSION # noqa: F401
version = '%s' version = '%s'
short_version = '%s' short_version = '%s'
# flake8: noqa E402 F401
from .lib.capnp import _CAPNP_VERSION_MAJOR as LIBCAPNP_VERSION_MAJOR
from .lib.capnp import _CAPNP_VERSION_MINOR as LIBCAPNP_VERSION_MINOR
from .lib.capnp import _CAPNP_VERSION_MICRO as LIBCAPNP_VERSION_MICRO
from .lib.capnp import _CAPNP_VERSION as LIBCAPNP_VERSION
""" """
if not filename: if not filename:
filename = os.path.join( filename = os.path.join(
@@ -63,6 +62,7 @@ with open('CHANGELOG.md', encoding='utf-8') as f:
changelog = '\nChangelog\n=============\n' + changelog changelog = '\nChangelog\n=============\n' + changelog
long_description += changelog long_description += changelog
class clean(_clean): class clean(_clean):
''' '''
Clean command, invoked with `python setup.py clean` Clean command, invoked with `python setup.py clean`
@@ -105,7 +105,8 @@ try:
except Exception: except Exception:
pass pass
from Cython.Distutils import build_ext as build_ext_c from Cython.Distutils import build_ext as build_ext_c # noqa: E402
class build_libcapnp_ext(build_ext_c): class build_libcapnp_ext(build_ext_c):
''' '''
@@ -114,7 +115,7 @@ class build_libcapnp_ext(build_ext_c):
def build_extension(self, ext): def build_extension(self, ext):
build_ext_c.build_extension(self, ext) build_ext_c.build_extension(self, ext)
def run(self): def run(self): # noqa: C901
if force_bundled_libcapnp: if force_bundled_libcapnp:
need_build = True need_build = True
elif force_system_libcapnp: elif force_system_libcapnp:
@@ -123,9 +124,10 @@ class build_libcapnp_ext(build_ext_c):
# Try to use capnp executable to find include and lib path # Try to use capnp executable to find include and lib path
capnp_executable = shutil.which("capnp") capnp_executable = shutil.which("capnp")
if capnp_executable: if capnp_executable:
self.include_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'include')] capnp_dir = os.path.dirname(capnp_executable)
self.library_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'lib{}'.format(8 * struct.calcsize("P")))] self.include_dirs += [os.path.join(capnp_dir, "..", "include")]
self.library_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'lib')] self.library_dirs += [os.path.join(capnp_dir, "..", "lib{}".format(8 * struct.calcsize("P")))]
self.library_dirs += [os.path.join(capnp_dir, "..", "lib")]
# Look for capnproto using pkg-config (and minimum version) # Look for capnproto using pkg-config (and minimum version)
try: try:
@@ -176,14 +178,16 @@ class build_libcapnp_ext(build_ext_c):
return build_ext_c.run(self) return build_ext_c.run(self)
extra_compile_args = ['--std=c++14'] extra_compile_args = ['--std=c++14']
extra_link_args = [] extra_link_args = []
if os.name == 'nt': if os.name == 'nt':
extra_compile_args = ['/std:c++14', '/MD'] extra_compile_args = ['/std:c++14', '/MD']
extra_link_args = ['/MANIFEST'] extra_link_args = ['/MANIFEST']
import Cython.Build import Cython.Build # noqa: E402
import Cython # noqa: F401 import Cython # noqa: E402
extensions = [Extension( extensions = [Extension(
'*', ['capnp/helpers/capabilityHelper.cpp', 'capnp/lib/*.pyx'], '*', ['capnp/helpers/capabilityHelper.cpp', 'capnp/lib/*.pyx'],
extra_compile_args=extra_compile_args, extra_compile_args=extra_compile_args,
@@ -208,14 +212,15 @@ setup(
}, },
install_requires=[], install_requires=[],
entry_points={ entry_points={
'console_scripts' : ['capnpc-cython = capnp._gen:main'] "console_scripts": ["capnpc-cython = capnp._gen:main"]
}, },
# PyPi info # PyPi info
description="A cython wrapping of the C++ Cap'n Proto library", description="A cython wrapping of the C++ Cap'n Proto library",
long_description=long_description, long_description=long_description,
long_description_content_type = 'text/markdown', long_description_content_type="text/markdown",
license='BSD', license='BSD',
author="Jacob Alexander", # <- Current maintainer; Original author -> Jason Paryani (setup.py only supports 1 author...) # (setup.py only supports 1 author...)
author="Jacob Alexander", # <- Current maintainer; Original author -> Jason Paryani
author_email="haata@kiibohd.com", author_email="haata@kiibohd.com",
url='https://github.com/capnproto/pycapnp', url='https://github.com/capnproto/pycapnp',
download_url='https://github.com/haata/pycapnp/archive/v%s.zip' % VERSION, download_url='https://github.com/haata/pycapnp/archive/v%s.zip' % VERSION,

View File

@@ -297,7 +297,13 @@ def test_timer():
assert test_timer_var is True assert test_timer_var is True
test_timer_var = False test_timer_var = False
promise = capnp.Promise(0).then(lambda x: time.sleep(.1)).then(lambda x: time.sleep(.1)).then(lambda x: set_timer_var()) promise = capnp.Promise(0).then(
lambda x: time.sleep(.1)
).then(
lambda x: time.sleep(.1)
).then(
lambda x: set_timer_var()
)
canceller = capnp.getTimer().after_delay(1).then(lambda: promise.cancel()) canceller = capnp.getTimer().after_delay(1).then(lambda: promise.cancel())