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

Fix HA 2025.2.0b0 deprecation warning #146

Merged
merged 4 commits into from
Feb 5, 2025

Conversation

TheZoker
Copy link
Contributor

@TheZoker TheZoker commented Jan 29, 2025

This fixes #145

Summary by CodeRabbit

  • Refactor
    • Updated type annotation for Zeroconf service discovery to use standardized import.
    • Improved code consistency in configuration flow handling.
  • New Features
    • Updated Home Assistant version in configuration for Philips Hue Play HDMI Sync Box.
  • Chores
    • Updated development and testing dependencies to newer versions.

Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

Walkthrough

The pull request updates the import and type annotation for ZeroconfServiceInfo in the config_flow.py file of the Hue Sync Box custom component. The change replaces the deprecated zeroconf.ZeroconfServiceInfo with the recommended ZeroconfServiceInfo from homeassistant.helpers.service_info.zeroconf, addressing a deprecation warning in Home Assistant 2025.2.0b0. Additionally, it updates various dependency versions in configuration files.

Changes

File Change Summary
custom_components/huesyncbox/config_flow.py Updated import and type annotation for ZeroconfServiceInfo
.github/workflows/push.yaml Updated Python version from 3.12 to 3.13
hacs.json Updated Home Assistant version from 2024.8.0 to 2025.2.0
requirements_dev.txt Updated homeassistant-stubs version from 2024.8.0 to 2025.2.0 and removed reference to requirements_test.txt
requirements_test.txt Updated pytest-homeassistant-custom-component version from 0.13.152 to 0.13.208

Assessment against linked issues

Objective Addressed Explanation
Address deprecation warning for ZeroconfServiceInfo [#145]

Possibly related PRs

  • Use config entry runtime data #106: The changes in this PR involve modifications to type annotations in custom_components/huesyncbox/config_flow.py, which are directly related to the changes made in the main PR regarding the async_step_zeroconf method's parameter type.
  • Bump min HA version for HACS #111: The changes in this PR, which update the Home Assistant version in hacs.json, are related to the changes in the main PR that also involve updating the Home Assistant version in the same file.

Poem

🐰 Hop, hop, through the code we go,
Zeroconf import, now neat and clean so!
Deprecated warning, no more in sight,
Home Assistant's path, now shining bright!
A rabbit's refactor, with type-safe delight! 🏡✨

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51ee8fb and c43746b.

📒 Files selected for processing (1)
  • requirements_test.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • requirements_test.txt

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -20,6 +20,7 @@
CONF_UNIQUE_ID,
)
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
Copy link
Owner

Choose a reason for hiding this comment

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

I guess the old import for zeroconf is unused now.
If so it should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@mvdwetering
Copy link
Owner

Thanks for the update, however I can only merge after Home Assistant 2025.2 has been released.

Because with these changes it now requires Home Assistant 2025.2 to run also some additional changes are needed:

  • The Github workflows need to be updated to use Python 3.13 (because 3.12 is dropped with HA 2025.2)
  • The versions for pytest-homeassistant-custom-component and homeassistant-stubs need to be updated to match HA 2025.2 (which will only be available after HA 2025.2 is out).
  • The minimum HA version in hacs.json needs to be updated

@TheZoker
Copy link
Contributor Author

TheZoker commented Jan 31, 2025

That's true!
Should I incorporate these things into my PR or do you want to open another one for that?

@TheZoker
Copy link
Contributor Author

I added those changes. You can always commit to this PR if you have any additional changes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 819a805 and 51ee8fb.

📒 Files selected for processing (4)
  • .github/workflows/push.yaml (1 hunks)
  • hacs.json (1 hunks)
  • requirements_dev.txt (1 hunks)
  • requirements_test.txt (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • hacs.json
🔇 Additional comments (2)
requirements_test.txt (1)

5-5: Verify compatibility with Python 3.13.

The version update aligns with HA 2025.2 requirements, but we need to verify compatibility with Python 3.13 as specified in the workflow.

Run this script to check package metadata:

.github/workflows/push.yaml (1)

18-18: Verify action compatibility with Python 3.13.

The update to Python 3.13 aligns with HA 2025.2 requirements. However, we should verify that all GitHub Actions and dependencies in the workflow support Python 3.13.

Run this script to check action versions and their Python support:

✅ Verification successful

Python 3.13 compatibility verified for all workflow actions

The workflow is fully compatible with Python 3.13:

  • actions/setup-python@v5 officially supports Python 3.13 as shown in their documentation
  • hassfest and HACS actions run in isolated Docker containers and are not affected by the workflow's Python version
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check latest versions and Python support for actions used in workflow

# Check actions/setup-python
echo "Checking actions/setup-python..."
curl -s https://api.github.com/repos/actions/setup-python/releases/latest | \
  jq -r '.tag_name, .body' | grep -i "python 3.13"

# Check home-assistant/actions/hassfest
echo "Checking hassfest action..."
curl -s https://api.github.com/repos/home-assistant/actions/commits/master | \
  jq -r '.commit.message' | grep -i "python"

# Check HACS action
echo "Checking HACS action..."
curl -s https://api.github.com/repos/hacs/action/releases/latest | \
  jq -r '.tag_name, .body' | grep -i "python"

Length of output: 552


Script:

#!/bin/bash
# Get workflow content and list all actions
echo "=== Workflow Actions ==="
cat .github/workflows/push.yaml

echo -e "\n=== Setup Python Support ==="
# Check setup-python releases without filtering
curl -s https://api.github.com/repos/actions/setup-python/releases/latest | jq -r '.tag_name, .body'

echo -e "\n=== Hassfest Action Config ==="
# Check hassfest action configuration
curl -s https://raw.githubusercontent.com/home-assistant/actions/master/hassfest/action.yml

echo -e "\n=== HACS Action Config ==="
# Check HACS action configuration
curl -s https://raw.githubusercontent.com/hacs/action/main/action.yml

Length of output: 4445


Script:

#!/bin/bash
# Check setup-python documentation for version support
echo "=== Setup Python Documentation ==="
curl -s https://raw.githubusercontent.com/actions/setup-python/main/README.md

# Check Python 3.13 availability in setup-python action
echo -e "\n=== Python 3.13 Support Check ==="
curl -s https://raw.githubusercontent.com/actions/setup-python/main/src/tools_versions_list.ts | grep "3.13"

Length of output: 7138

@@ -1,4 +1,4 @@
-r requirements_test.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Critical dependencies missing after requirements_test.txt removal

The following required dependencies are missing in requirements_dev.txt after removing the reference to requirements_test.txt:

  • mypy (needed for type checking)
  • pytest-homeassistant-custom-component (required for component testing)
  • zeroconf (required for network discovery)

These dependencies should be explicitly added to requirements_dev.txt to maintain development and testing functionality.

🔗 Analysis chain

Verify impact of removing requirements_test.txt reference.

The removal of -r requirements_test.txt might cause missing dependencies. Please ensure all required test dependencies are explicitly listed in this file.

Run this script to check for any missing dependencies:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare dependencies between requirements files
# Check for any dependencies that might be missing after removal

# Get unique dependencies from requirements_test.txt
test_deps=$(cat requirements_test.txt | grep -v "^-r" | grep -v "^#" | cut -d'=' -f1)

# Check if these dependencies exist in requirements_dev.txt
for dep in $test_deps; do
  if ! grep -q "$dep" requirements_dev.txt; then
    echo "Warning: $dep from requirements_test.txt is not in requirements_dev.txt"
  fi
done

Length of output: 895

@@ -1,4 +1,4 @@
-r requirements_test.txt

awesomeversion>=24.0.0
homeassistant-stubs==2024.8.0
homeassistant-stubs==2025.2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Version 2025.2.0 is not available on PyPI

The latest available version of homeassistant-stubs is 2025.1.4. Since the package follows calendar versioning, version 2025.2.0 would represent the February 2025 release, which is not yet available. Please update the requirement to use the latest stable version (2025.1.4).

🔗 Analysis chain

Version 2025.2.0 is not yet released.

The PR objectives indicate that Home Assistant 2025.2 is not yet officially released. This dependency version might not be available yet.

Run this script to verify package availability:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the package version exists on PyPI

curl -s https://pypi.org/pypi/homeassistant-stubs/json | jq -r '.releases | keys[]' | grep "2025.2.0" || echo "Version 2025.2.0 not found"

Length of output: 164


Script:

#!/bin/bash
# Description: List the latest 5 versions of homeassistant-stubs
curl -s https://pypi.org/pypi/homeassistant-stubs/json | jq -r '.releases | keys[]' | sort -V | tail -n 5

Length of output: 154

@mvdwetering
Copy link
Owner

Sorry for the delays.
All green now, will merge tomorrow.

@mvdwetering mvdwetering merged commit f74dc64 into mvdwetering:dev Feb 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants