core icon indicating copy to clipboard operation
core copied to clipboard

Bump roombapy to 1.6.11

Open mib1185 opened this issue 1 year ago • 2 comments

Proposed change

release-notes: https://github.com/pschmitt/roombapy/releases/tag/1.6.11 diff: https://github.com/pschmitt/roombapy/compare/1.6.10...1.6.11

Type of change

  • [x] Dependency upgrade
  • [x] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [ ] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #109772
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • [ ] The code change is tested and works locally.
  • [ ] Local tests pass. Your PR cannot be merged unless tests pass
  • [ ] There is no commented out code in this PR.
  • [ ] I have followed the development checklist
  • [ ] I have followed the perfect PR recommendations
  • [ ] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • [ ] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [ ] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • [ ] Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

mib1185 avatar Feb 16 '24 22:02 mib1185

Hey there @pschmitt, @cyr-ius, @shenxn, @xitee1, mind taking a look at this pull request as it has been labeled with an integration (roomba) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of roomba can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign roomba Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

home-assistant[bot] avatar Feb 16 '24 22:02 home-assistant[bot]

mehhh ... pydantic conflict 🙄

mib1185 avatar Feb 16 '24 23:02 mib1185

Lovely. They either should make it work with Pydantic V1 and support v2 via shims. (Since I'm trying to get HA to migrate to V2 safely, I don't think it's a good idea to accept new dependencies with Pydantic V1 without support for working with v2 (using the included shims)). Or they should move away completely to another lib like mashumaro. I'll try to find some time to help with this since I'm also a Roomba user :)

joostlek avatar Feb 17 '24 09:02 joostlek

@joostlek I'll open follow-up PR to roombapy in a next few hours, thanks for pointing this. ~So, which version of Pydantic should library target for?~ Found https://github.com/home-assistant/core/issues/99218.

Orhideous avatar Feb 17 '24 18:02 Orhideous

Well, in a new patch version it should work with Pydantic v1 and v2, added some tests for this.

UPD: @mib1185 1.6.12 is already available :)

Orhideous avatar Feb 17 '24 19:02 Orhideous

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar Feb 20 '24 22:02 home-assistant[bot]

It's due to stricter invariants in roombapy now. I'd like to enforce strict typing in this integration soon.

Here is a patch for test_roomba_integration.py that should fix tests.

-   roomba = RoombaInfo(
-       hostname="irobot-BLID",
-       robot_name="robot_name",
-       ip=MOCK_IP,
-       mac="mac",
-       firmware="firmware",
-       sku="sku",
-       capabilities="capabilities",
-   )
+   roomba = RoombaInfo(
+       hostname="irobot-BLID",
+       robotname="robot_name",
+       ip="1.2.3.4",
+       mac="mac",
+       sw="firmware",
+       sku="sku",
+       cap={"capability": 1},
+   )

Orhideous avatar Feb 20 '24 22:02 Orhideous

We can enable strict typing in a follow up, but this PR now breaks some tests, that should be fixed first.

joostlek avatar Feb 20 '24 22:02 joostlek

Also, please don't forget to add a py.typed file for enabling mypy to read types from the lib. https://peps.python.org/pep-0561/

joostlek avatar Feb 20 '24 22:02 joostlek

Sure, I hope to finish polishing the library and integration for the next release. But this PR isn't mine, so I can only help with the patch. Might be worth opening the next PR myself, just to be sure.

Orhideous avatar Feb 20 '24 22:02 Orhideous

Tests are failing, can you take a look?

i'm not familiar with pydantic so i'm not sure what is wrong here or which side needs to be adjusted

error

tests/components/roomba/test_config_flow.py:99: in _mocked_discovery
    roomba = RoombaInfo(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>   ???
E   pydantic.error_wrappers.ValidationError: 3 validation errors for RoombaInfo
E   sw
E     field required (type=value_error.missing)
E   robotname
E     field required (type=value_error.missing)
E   cap
E     field required (type=value_error.missing)

tests/components/roomba/test_config_flow.py

def _mocked_discovery(*_):
    roomba_discovery = MagicMock()

    roomba = RoombaInfo(
        hostname="irobot-BLID",
        robot_name="robot_name",
        ip=MOCK_IP,
        mac="mac",
        firmware="firmware",
        sku="sku",
        capabilities={"cap1": 1},
    )

roombapy/roomba_info.py

class RoombaInfo(BaseModel):
    hostname: str
    firmware: str = Field(alias="sw")
    ip: str
    mac: str
    robot_name: str = Field(alias="robotname")
    sku: str
    capabilities: Dict[str, int] = Field(alias="cap")
    password: Optional[str] = None

EDIT: when using the "alias" names for the properties, than it works

def _mocked_discovery(*_):
    roomba_discovery = MagicMock()

    roomba = RoombaInfo(
        hostname="irobot-BLID",
        robotname="robot_name",
        ip=MOCK_IP,
        mac="mac",
        sw="firmware",
        sku="sku",
        cap={"cap1": 1},
    )

that's weird 🤨

mib1185 avatar Feb 21 '24 16:02 mib1185