Skip to content

Bump pyprusalink to 3.0.0#170480

Merged
joostlek merged 36 commits into
home-assistant:devfrom
heikkih:chore/prusalink-bump-3.0.0
May 26, 2026
Merged

Bump pyprusalink to 3.0.0#170480
joostlek merged 36 commits into
home-assistant:devfrom
heikkih:chore/prusalink-bump-3.0.0

Conversation

@heikkih
Copy link
Copy Markdown
Contributor

@heikkih heikkih commented May 13, 2026

Proposed change

This PR is intentionally scoped to a minimal dependency bump for PrusaLink.

Included scope:

  • Bump pyprusalink to 3.0.0.
  • Apply only compatibility updates required for Home Assistant to work with the updated upstream API/typing.
  • Include minimal cast() adjustments required by the stricter typing surface in pyprusalink 3.0.0.

Out of scope:

  • Broader job state semantics (unknown vs unavailable) are intentionally deferred and will be handled in a separate follow-up PR after this bump is merged.
  • Test updates and additional cleanup/refactors are intentionally deferred to a separate follow-up PR to keep this dependency bump minimal.

Dependency reference:

Type of change

  • Dependency upgrade
  • 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

Checklist

  • I understand the code I am submitting and can explain how it works.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • 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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR bumps the PrusaLink integration’s pyprusalink dependency to 3.0.0 and updates the integration/test code to accommodate the library’s breaking change where get_job() can now return None.

Changes:

  • Bump pyprusalink to 3.0.0 across the integration manifest and generated requirements pins.
  • Update the PrusaLink coordinators/entities to correctly handle JobInfo | None payloads from the job endpoint.
  • Align sensors and tests with the new idle-job behavior and stricter typing introduced by pyprusalink’s py.typed.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
homeassistant/components/prusalink/manifest.json Bumps integration requirement pin to pyprusalink==3.0.0.
requirements_all.txt Updates generated dependency pin for pyprusalink.
requirements_test_all.txt Updates generated test dependency pin for pyprusalink.
homeassistant/components/prusalink/coordinator.py Makes the job coordinator nullable (`JobInfo
homeassistant/components/prusalink/entity.py Prevents available_fn evaluation when coordinator data is None (avoids idle-job crashes).
homeassistant/components/prusalink/sensor.py Updates sensor value/availability logic and adds typing workarounds for stricter upstream types.
tests/components/prusalink/conftest.py Adjusts job API idle fixture to return None (matching pyprusalink>=3.0.0).

Comment thread tests/components/prusalink/conftest.py
Comment thread homeassistant/components/prusalink/sensor.py
Comment thread homeassistant/components/prusalink/sensor.py Outdated
Comment thread homeassistant/components/prusalink/sensor.py Outdated
@heikkih heikkih marked this pull request as draft May 13, 2026 11:51
heikkih added a commit to heikkih/homeassistant-core that referenced this pull request May 13, 2026
Follow-up to home-assistant#170480, addressing the two `# type: ignore` comments that
PR added to the `job.filename` and `job.finish` sensors. Both lambdas
are guarded at runtime by `available_fn` (verifying `data["file"]` and
`data["time_remaining"]` are not None respectively), but mypy doesn't
follow the guarantee from `available_fn` into `value_fn`.

Switch to the inner-cast pattern already used on the
`printer.telemetry.material` sensor:

- `job.filename`: `cast(JobFilePrint, data["file"])["display_name"]`
  narrows `JobFilePrint | None` so the index is type-safe.
- `job.finish`: `cast(int, data["time_remaining"])` narrows
  `int | None` so it can be passed to `timedelta(seconds=...)`.

Runtime behaviour is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@heikkih heikkih marked this pull request as ready for review May 13, 2026 12:00
Copilot AI review requested due to automatic review settings May 13, 2026 12:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/prusalink/coordinator.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Comment thread homeassistant/components/prusalink/entity.py
Comment thread homeassistant/components/prusalink/sensor.py
@home-assistant home-assistant Bot marked this pull request as draft May 13, 2026 16:39
@home-assistant
Copy link
Copy Markdown
Contributor

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

Learn more about our pull request process.

Copilot AI review requested due to automatic review settings May 15, 2026 10:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread tests/components/prusalink/conftest.py
heikkih added a commit to heikkih/homeassistant-core that referenced this pull request May 16, 2026
Follow-up to home-assistant#170480, addressing the two `# type: ignore` comments that
PR added to the `job.filename` and `job.finish` sensors. Both lambdas
are guarded at runtime by `available_fn` (verifying `data["file"]` and
`data["time_remaining"]` are not None respectively), but mypy doesn't
follow the guarantee from `available_fn` into `value_fn`.

Switch to the inner-cast pattern already used on the
`printer.telemetry.material` sensor:

- `job.filename`: `cast(JobFilePrint, data["file"])["display_name"]`
  narrows `JobFilePrint | None` so the index is type-safe.
- `job.finish`: `cast(int, data["time_remaining"])` narrows
  `int | None` so it can be passed to `timedelta(seconds=...)`.

Runtime behaviour is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@heikkih heikkih force-pushed the chore/prusalink-bump-3.0.0 branch from fa62279 to 26f5a7e Compare May 16, 2026 14:01
Copilot AI review requested due to automatic review settings May 16, 2026 14:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread homeassistant/components/prusalink/sensor.py Outdated
Comment thread homeassistant/components/prusalink/sensor.py Outdated
Comment thread tests/components/prusalink/conftest.py
Comment thread tests/components/prusalink/conftest.py
@heikkih heikkih requested a review from Copilot May 16, 2026 14:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread homeassistant/components/prusalink/sensor.py Outdated
Comment thread tests/components/prusalink/conftest.py
Comment thread tests/components/prusalink/conftest.py
@heikkih heikkih reopened this May 21, 2026
Copilot AI review requested due to automatic review settings May 21, 2026 11:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread tests/components/prusalink/conftest.py
Comment thread homeassistant/components/prusalink/coordinator.py
Comment thread homeassistant/components/prusalink/coordinator.py
@heikkih
Copy link
Copy Markdown
Contributor Author

heikkih commented May 21, 2026

I've cleaned this up to handle the version-bump in a minimal way.

The following will be handled in followup-PRs. Builds on this, so they will be opened when this one is merged:

  • enhanced test-coverage
  • Job-state-semantics (unknown instead of unavailable) - Breaking change
  • other cleanups and refactors.

Ready for review.

@heikkih heikkih marked this pull request as ready for review May 21, 2026 11:25
Copilot AI review requested due to automatic review settings May 21, 2026 11:25
@home-assistant home-assistant Bot requested a review from erwindouna May 21, 2026 11:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment on lines +126 to +133
def mock_job_api_idle() -> Generator[None]:
"""Mock PrusaLink job API having no job.

pyprusalink >= 3.0.0 returns `None` from `get_job()` on HTTP 204 when
no job is running, rather than an empty dict as in 2.x.
"""
with patch("pyprusalink.PrusaLink.get_job", return_value=None):
yield None
Comment thread homeassistant/components/prusalink/coordinator.py
Comment thread homeassistant/components/prusalink/sensor.py
Copy link
Copy Markdown
Member

@erwindouna erwindouna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @heikkih. Please elaborate what's related to the dependency bump and what's not. All the work that's not related to the bump, then please split that off from this PR and create separate PRs. :)

Comment thread homeassistant/components/prusalink/binary_sensor.py Outdated
Comment thread homeassistant/components/prusalink/config_flow.py Outdated
Comment thread homeassistant/components/prusalink/coordinator.py
@home-assistant home-assistant Bot marked this pull request as draft May 21, 2026 12:56
Copilot AI review requested due to automatic review settings May 21, 2026 17:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread tests/components/prusalink/conftest.py
Comment thread homeassistant/components/prusalink/binary_sensor.py Outdated
@heikkih
Copy link
Copy Markdown
Contributor Author

heikkih commented May 21, 2026

Thanks for the review @erwindouna

My local venv was pointing at the older pyprusalink 2.2.0 due to parallell work in a different branch, so sorry for the noise earlier.

I've updated and gone through all changes manually. All changes are now relevant to the 3.0.0-bump, specifically the tighter typing in it, hence the need for the casts for now. I will handle these better (with some refactoring) in a follow-up PR, but now it is as minimal as I can get it, while still working correctly and passing all QA-jobs :)

I'll set this as ready for review now.

@heikkih heikkih marked this pull request as ready for review May 21, 2026 17:46
Copilot AI review requested due to automatic review settings May 21, 2026 17:46
@home-assistant home-assistant Bot requested a review from erwindouna May 21, 2026 17:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread homeassistant/components/prusalink/config_flow.py
Comment thread tests/components/prusalink/conftest.py
@joostlek joostlek dismissed erwindouna’s stale review May 26, 2026 19:59

PR seem to be cut down

@joostlek joostlek merged commit 81efe6d into home-assistant:dev May 26, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants