BlueZ version (bluetoothctl -v) in case of Linux: NA
Description
Mypy treats kwargs that are Unpacked as required. In fact, these kwargs were always intended as platform-specific optional arguments.
Mypy will diagnose missing kwargs as errors. In bleak, this occurs for any function that types kwargs as Unpack[ExtraArgs]. These include the methods discover, find_device_by_address, find_device_by_name, and find_device_by_filter.
Where a more friendly solution may be to use Generic and type aliases, use of Unpack is a welcome improvement over kwargs, so I believe that it's simple enough to add total=False because ALL of the kwargs are optional. Refer to https://peps.python.org/pep-0692/#required-and-non-required-keys. If finer grained control is required, then I suggest Generic and Type Aliases so that the user can see the arguments in their editor instead of having to rely on documentation.
mypy . will diagnose every missing kwarg as error:
smpclient\blah.py:5: error: Missing named argument "service_uuids" for "find_device_by_address" of "BleakScanner" [call-arg]
smpclient\blah.py:5: error: Missing named argument "scanning_mode" for "find_device_by_address" of "BleakScanner" [call-arg]
smpclient\blah.py:5: error: Missing named argument "bluez" for "find_device_by_address" of "BleakScanner" [call-arg]
smpclient\blah.py:5: error: Missing named argument "cb" for "find_device_by_address" of "BleakScanner" [call-arg]
smpclient\blah.py:5: error: Missing named argument "backend" for "find_device_by_address" of "BleakScanner" [call-arg]
poetry run mypy . within the bleak repo generates errors, and bleak does not enforce mypy, so it makes sense that this would only be noticed downstream.
bluetoothctl -v
) in case of Linux: NADescription
Mypy treats kwargs that are
Unpack
ed as required. In fact, these kwargs were always intended as platform-specific optional arguments.Mypy will diagnose missing kwargs as errors. In bleak, this occurs for any function that types kwargs as
Unpack[ExtraArgs]
. These include the methods discover, find_device_by_address, find_device_by_name, and find_device_by_filter.Where a more friendly solution may be to use
Generic
and type aliases, use ofUnpack
is a welcome improvement over kwargs, so I believe that it's simple enough to add total=False because ALL of the kwargs are optional. Refer to https://peps.python.org/pep-0692/#required-and-non-required-keys. If finer grained control is required, then I suggest Generic and Type Aliases so that the user can see the arguments in their editor instead of having to rely on documentation.What I Did
Ran mypy 1.7.1 on a file like:
mypy .
will diagnose every missing kwarg as error:Logs
N/A