Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_set_property_by[value_type4-1] fails on Python 3.13 #1997

Closed
mweinelt opened this issue Jan 3, 2025 · 2 comments · Fixed by #1993
Closed

test_set_property_by[value_type4-1] fails on Python 3.13 #1997

mweinelt opened this issue Jan 3, 2025 · 2 comments · Fixed by #1993
Labels

Comments

@mweinelt
Copy link

mweinelt commented Jan 3, 2025

Describe the bug
The test_set_property_by[value_type4-1] broke on Python 3.13, but works on 3.12.

Visible in the CI: https://github.com/rytilahti/python-miio/actions/runs/11759608046/job/32759267643

Version information (please complete the following information):

  • OS: Linux
  • python-miio: 0.5.12

To Reproduce
Steps to reproduce the behavior:

  1. Run the testsuite

Expected behavior
Home Assistant requires Python 3.13 by Feb 2025, so I hope that the python-miio test suite works with 3.13.

Console output

_____________________ test_set_property_by[value_type4-1] ______________________

dev = <MiotDevice: 127.0.0.1 (token: 68ffffffffffffffffffffffffffffff)>
value_type = functools.partial(<function MiotValueType._str2bool at 0x7ffff54b9ee0>)
value = '1'

    @pytest.mark.parametrize(
        "value_type,value",
        [
            (None, 1),
            (MiotValueType.Int, "1"),
            (MiotValueType.Float, "1.2"),
            (MiotValueType.Str, "str"),
            (MiotValueType.Bool, "1"),
        ],
    )
    def test_set_property_by(dev, value_type, value):
        siid = 1
        piid = 1
>       _ = dev.set_property_by(siid, piid, value, value_type)

miio/tests/test_miotdevice.py:61: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
miio/click_common.py:184: in _wrap
    return func(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MiotDevice: 127.0.0.1 (token: 68ffffffffffffffffffffffffffffff)>
siid = 1, piid = 1, value = '1'
value_type = functools.partial(<function MiotValueType._str2bool at 0x7ffff54b9ee0>)

    @command(
        click.argument("siid", type=int),
        click.argument("piid", type=int),
        click.argument("value"),
        click.argument(
            "value_type", type=EnumType(MiotValueType), required=False, default=None
        ),
    )
    def set_property_by(
        self,
        siid: int,
        piid: int,
        value: Union[int, float, str, bool],
        value_type: Any = None,
    ):
        """Set a single property (siid/piid) to given value.
    
        value_type can be given to convert the value to wanted type, allowed types are:
        int, float, bool, str
        """
        if value_type is not None:
>           value = value_type.value(value)
E           AttributeError: 'functools.partial' object has no attribute 'value'

miio/miot_device.py:142: AttributeError
@mweinelt mweinelt added the bug label Jan 3, 2025
@rytilahti
Copy link
Owner

I think #1993 fixes this, but it hasn't been tested so far.

@rytilahti rytilahti linked a pull request Jan 4, 2025 that will close this issue
@mweinelt
Copy link
Author

mweinelt commented Jan 4, 2025

Thanks, that looks perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants