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

PR 633 'Use Python 3.10 syntax' appears to be missing from all releases #986

Open
cs12ag opened this issue Feb 10, 2025 · 5 comments
Open

Comments

@cs12ag
Copy link

cs12ag commented Feb 10, 2025

Commit 752370b appears to be missing from all releases created since this commit was merged to master.

I'm attempting to fix a bug in the tradfri home-assistant core component, and I've upgraded the version of pytradfri that the component is using - to 13.0.0. I'm now struggling with a bunch of pydantic validation errors coming out of the DeviceResponse class in pytradfri/devices/__init__.py .
The errors I'm getting are as follows:

    def __init__(self, raw: TypeRaw) -> None:
        """Initialize base object."""
>       self.raw = self._model_class(**raw)
E       pydantic_core._pydantic_core.ValidationError: 11 validation errors for DeviceResponse
E       15025
E         Field required [type=missing, input_value={'3': {'0': 'IKEA of Swed...: 1510009959, '9054': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       15015
E         Field required [type=missing, input_value={'3': {'0': 'IKEA of Swed...: 1510009959, '9054': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3.9
E         Field required [type=missing, input_value={'0': 'IKEA of Sweden', '... '3': '1.2.214', '6': 1}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3311.0.5711
E         Field required [type=missing, input_value={'5850': 1, '5851': 250, '9003': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3311.0.5706
E         Field required [type=missing, input_value={'5850': 1, '5851': 250, '9003': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3311.0.5709
E         Field required [type=missing, input_value={'5850': 1, '5851': 250, '9003': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3311.0.5710
E         Field required [type=missing, input_value={'5850': 1, '5851': 250, '9003': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3311.0.5707
E         Field required [type=missing, input_value={'5850': 1, '5851': 250, '9003': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3311.0.5708
E         Field required [type=missing, input_value={'5850': 1, '5851': 250, '9003': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       15014
E         Field required [type=missing, input_value={'3': {'0': 'IKEA of Swed...: 1510009959, '9054': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing
E       3312
E         Field required [type=missing, input_value={'3': {'0': 'IKEA of Swed...: 1510009959, '9054': 0}, input_type=dict]
E           For further information visit https://errors.pydantic.dev/2.10/v/missing

/home/vscode/.local/ha-venv/lib/python3.13/site-packages/pytradfri/resource.py:40: ValidationError

My current theory is that the DeviceResponse class is being incorrectly instantiated with the 'optional' fields being interpreted as required by pydantic (leading to the output seen above), due to the usage of the 'Optional[]' type-hint.
FYI this specific set of errors is produced when I use the standard light response in a test.

Please can this library be re-released with this commit included?

@ggravlingen
Copy link
Member

ggravlingen commented Feb 10, 2025

If no one beats me to it, I will have a look tonight and prepare for a new release.

There are quite a few changes that need to be made in home assistant for the new version of this library to work, but I guess you've already spotted that?

@MartinHjelmare
Copy link
Contributor

Go ahead and release version 14. 👍

I have this branch where tests pass with latest pytradfri locally:

https://github.com/home-assistant/core/tree/update-tradfri-for-latest-pytradfri

I can bump pytradfri in that branch after we've released version 14. I don't have time right now to submit it as I think it should be split in at least two pieces, one for the migration of the device identifiers and one for the rest. But I don't mind if someone copies that work and submits it in two pieces.

@cs12ag
Copy link
Author

cs12ag commented Feb 10, 2025

I have a PR open for the bug against the devide-identifiers in core/components/tradfri already: home-assistant/core#136060 - my migration is actually something similar (in that it's converting the ID from a number to a string), but there's actually a unique-ness issue occurring if there are multiple gateways configured in the component.
If I get time, I'll copy your changes into my branch and PR and credit you.

@MartinHjelmare
Copy link
Contributor

Note that I don't believe we need to bump the library in Home Assistant before we do the device entry identifier migration. It's better to do the library bump separately afterwards in a separate PR.

@ggravlingen
Copy link
Member

ggravlingen commented Feb 10, 2025

I've released v14.0.0, should be on pypi in a few minutes.

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

No branches or pull requests

3 participants