python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

FutureWarning: functools.partial usage in miot_device.py causes warning on Python 3.13+

Open Bellavista opened this issue 5 months ago • 5 comments

Hi,

I’m using the library with Python 3.13 and I’m seeing the following warning during import:

WARNING (ImportExecutor_0) [py.warnings] /usr/local/lib/python3.13/site-packages/miio/miot_device.py:23: FutureWarning: functools.partial will be a method descriptor in future Python versions; wrap it in enum.member() if you want to preserve the old behavior Bool = partial(_str2bool) It looks like the usage of functools.partial in miot_device.py line 23 will no longer work as expected in future Python versions (3.14+).

Would it be possible to update the code to avoid this warning and keep compatibility with future Python versions?

Thanks for your great work on the library!

Bellavista avatar Jun 26 '25 18:06 Bellavista

Hi, if I don't misrecall, this is already fixed in the git master (and maybe in the 0.6.0 pre-release, which is also available on pypi).

Thanks for the reminder though, that I should definitely create a new release before the 3.14 ships. Alas, I don't currently have neither time nor test devices to do necessary testing..

edit: there's also discussion in the related downstream issue: https://github.com/home-assistant/core/issues/132902

rytilahti avatar Jun 26 '25 19:06 rytilahti

Hi, if I don't misrecall, this is already fixed in the git master (and maybe in the 0.6.0 pre-release, which is also available on pypi).

Thanks for the reminder though, that I should definitely create a new release before the 3.14 ships. Alas, I don't currently have neither time nor test devices to do necessary testing..

edit: there's also discussion in the related downstream issue: home-assistant/core#132902

I think it doesn't end up with only testing. I have devices to test, but the changes are too much for just simple dependency bump (see https://github.com/home-assistant/core/issues/132902#issuecomment-2610554679).

I know it creates some overhead, but at this point I think it would be better to branch of the latest release that is in use (python-miio==0.5.12) and just add this fix

thecode avatar Jul 07 '25 09:07 thecode

something wrong!

windows11 python3.13, Name: python-miio Version: 0.6.0.dev0

miiocli device --ip 192.168.x.x --token xx raw_command get_prop "[tds_warn_thd]"

ERROR:miio.click_common:Exception: argument of type 'bool' is not iterable Traceback (most recent call last): File "C:\Users\Zhang jun\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\miio\click_common.py", line 55, in call return self.main(*args, **kwargs) ~~~~~~~~~^^^^^^^^^^^^^^^^^ File "C:\Users\Zhang jun\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\click\core.py", line 1363, in main rv = self.invoke(ctx) File "C:\Users\Zhang jun\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\click\core.py", line 1830, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^ File "C:\Users\Zhang jun\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\click\core.py", line 1824, in invoke cmd_name, cmd, args = self.resolve_command(ctx, args) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^ File "C:\Users\Zhang jun\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\click\core.py", line 1871, in resolve_command cmd = self.get_command(ctx, cmd_name) File "C:\Users\Zhang jun\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\miio\click_common.py", line 274, in get_command if cmd_name not in self.commands: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'bool' is not iterable

xiaxianguyue avatar Jul 08 '25 17:07 xiaxianguyue

An updated made to dependency click is what broke it, run this:

pip install click==8.0.4 --force-reinstall

PatrickChenHZ avatar Aug 16 '25 12:08 PatrickChenHZ

Is this going to be fixed or do I need to supress the warning from my project to prevent people to create unnecessary issues on my repo?

Tasshack avatar Nov 07 '25 01:11 Tasshack

According to above comments, this is likely already fixed. My guess is that it did not make it yet to the (formally) distributed version of the library yet, hence everybody is still seeing this error (e.g. in Home Assistant). The last release of this library was in 2022 and rytilahti indicated he has limited time to prep a new release (although things might have changed in the meantime).

Xirt avatar Dec 07 '25 22:12 Xirt