You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect type reported by type checker for async properties #63
When trying to access an async property of an interface, both mypy and pyright report the wrong type. In this example, I'd expect access_point.ssid to report type bytes, but it doesn't. Also, if I call get_async() directly it reports a different type for pyright.
$ mypy type_test_async.py
type_test_async.py:10: error: Need type annotation for "ssid" [var-annotated]
type_test_async.py:11: note: Revealed type is "Any"
type_test_async.py:13: note: Revealed type is "Any"
Found 1 error in 1 file (checked 1 source file)
pyright output:
$ pyright type_test_async.py
./type_test_async.py
./type_test_async.py:11:21 - information: Type of "ssid" is "T@__await__"
./type_test_async.py:13:21 - information: Type of "ssid" is "Unknown"
0 errors, 0 warnings, 2 informations
In both cases, I would expect for the revealed type to be bytes. At runtime, my code works and reveal_type prints Runtime type is 'bytes', so I guess the problem has to do with the type hints. Also, the blocking API doesn't have this problem and correctly report bytes.
importsdbusimportsdbus_block.networkmanagerasnm_blockfromtypingimportreveal_typesystem_bus=sdbus.sd_bus_open_system()
defget_wifi_block_connections(wifi_device: nm_block.NetworkDeviceWireless):
forpathinwifi_device.access_points:
access_point=nm_block.AccessPoint(path, system_bus)
ssid=access_point.ssidreveal_type(ssid) # Both mypy and pyright report `bytes`
Activity
igo95862 commentedon Feb 15, 2024
Hello @ValdezFOmar ,
What version of python-sdbus are you using?
Is it only
.ssidproperty that has those issues or do other properties have those issues as well?igo95862 commentedon Feb 15, 2024
I tested the typing of a property using the D-Bus
org.freedesktop.DBusand I could not replicate those issues:igo95862 commentedon Feb 15, 2024
Hmmmm. There might be an issue with the 0.11.1 but the master branch seems fine. Could you give a test to the python-sdbus master branch?
ValdezFOmar commentedon Feb 15, 2024
I'm using python-sdbus 0.11.1
Any async property that I tried to access had this issue, I only use
ssidas an example.I did and now both mypy and pyright report the correct types for properties. Thank you.
igo95862 commentedon Feb 16, 2024
Should I release the version 0.11.2 which will fix the issue? The current master branch has some really big reworks.
ValdezFOmar commentedon Feb 16, 2024
Feel free to do what you see fit, I'm not in a hurry and it's not that big of a problem. For me the issue is fixed either way.