robotpy / pyntcore

Moved to https://github.com/robotpy/mostrobotpy
2 stars 5 forks source link

Listener examples in pynetworktables docs fail to complie with pyntcore #23

Closed cttdev closed 1 year ago

cttdev commented 3 years ago

The Listener example in the pynetworktables docs throw the following error when complied with pyntcore:

NetworkTables.addConnectionListener(connectionListener, immediateNotify=True)
TypeError: addConnectionListener(): incompatible function arguments. The following argument types are supported:
    1. (self: _pyntcore._ntcore.NetworkTablesInstance, callback: Callable[[_pyntcore._ntcore.ConnectionNotification], None], immediate_notify: bool) -> int

Invoked with: <_pyntcore._ntcore.NetworkTablesInstance object at 0x7f67138851b0>, <function connectionListener at 0x7f6713879e50>; kwargs: immediateNotify=True
auscompgeek commented 3 years ago

Hm, we fixed that keyword argument in #16.

It's quite possible the callback arguments still need to be fixed, but I didn't think pybind11 does that level of introspection.

TheTripleV commented 3 years ago

I ran locally on 2020.3.2.2 earlier and while it got past that line, it errored on:

➜  ctt python le.py 127.0.0.1
Traceback (most recent call last):
  File "le.py", line 40, in <module>
    sd.addEntryListener(valueChanged)
TypeError: addEntryListener(): incompatible function arguments. The following argument types are supported:
    1. (self: _pyntcore._ntcore.NetworkTable, listener: Callable[[_pyntcore._ntcore.NetworkTable, str, _pyntcore._ntcore.NetworkTableEntry, _pyntcore._ntcore.Value, int], None], flags: int) -> int
    2. (self: _pyntcore._ntcore.NetworkTable, key: str, listener: Callable[[_pyntcore._ntcore.NetworkTable, str, _pyntcore._ntcore.NetworkTableEntry, _pyntcore._ntcore.Value, int], None], flags: int) -> int

Invoked with: <_pyntcore._ntcore.NetworkTable object at 0x10e4a7470>, <function valueChanged at 0x10e9b4040>

It appears that pyntcore addEntryListener requires flags to be passed in while pynetworktables does not.

auscompgeek commented 3 years ago

Right, it looks like we need to copy the NetworkTablesInstance addEntryListener code to NetworkTable then.