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

chore: typing AC #33

Merged
merged 2 commits into from
Jun 4, 2024
Merged

Conversation

chemelli74
Copy link
Member

@chemelli74 chemelli74 commented May 28, 2024

Summary by CodeRabbit

  • Refactor
    • Added type annotations to methods and variables across various classes to enhance code clarity and type safety.

@codecov-commenter
Copy link

codecov-commenter commented May 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 63 lines in your changes missing coverage. Please review.

Project coverage is 6.39%. Comparing base (7e66870) to head (4b8274a).
Report is 5 commits behind head on main.

Files Patch % Lines
midealocal/devices/ac/message.py 0.00% 39 Missing ⚠️
midealocal/devices/ac/__init__.py 0.00% 24 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main     #33      +/-   ##
========================================
- Coverage   6.40%   6.39%   -0.01%     
========================================
  Files         77      77              
  Lines       6588    6597       +9     
========================================
  Hits         422     422              
- Misses      6166    6175       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

coderabbitai bot commented Jun 4, 2024

Walkthrough

The recent changes focus on enhancing type safety and clarity in the midealocal/devices/ac and midealocal/devices/ac/message.py modules. Type hints were added to method signatures, constructors, and variable declarations using Python's typing module. These modifications ensure better code readability, maintainability, and error detection during development.

Changes

Files Change Summary
midealocal/devices/ac/__init__.py Added type hints to method signatures, constructors, and variable declarations to improve type safety.
midealocal/devices/ac/message.py Added type annotations to constructors and return types for various classes to enhance code clarity and safety.

Poem

In the code where bytes do flow,
Type hints now begin to show.
With clarity and safety in mind,
Bugs and errors left behind.
Python's typing leads the way,
For a brighter, clearer coding day!
🐰✨📜


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@chemelli74 chemelli74 marked this pull request as ready for review June 4, 2024 08:08
midealocal/devices/ac/__init__.py Outdated Show resolved Hide resolved
midealocal/devices/ac/__init__.py Outdated Show resolved Hide resolved
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7e66870 and 4b8274a.

Files selected for processing (2)
  • midealocal/devices/ac/init.py (8 hunks)
  • midealocal/devices/ac/message.py (22 hunks)
Additional comments not posted (30)
midealocal/devices/ac/__init__.py (13)

88-88: Ensure the constructor's return type is correctly annotated.


136-136: Type annotation added for _fresh_air_version enhances clarity and type safety.


147-147: Proper return type annotation for temperature_step method improves type checking.


151-151: Type annotation for fresh_air_fan_speeds method is correctly specified.


154-161: Ensure the return type for build_query method is correctly specified and matches the expected types.


174-175: Adding type hints to the process_message method parameters and return type enhances type safety.


219-219: Return type for make_message_set method is correctly annotated.


242-242: Return type for make_subptotocol_message_set method is correctly annotated.


260-261: Return type for make_message_uniq_set method is correctly annotated.


268-268: Type annotations for parameters in set_attribute method enhance clarity and type safety.


356-356: Type annotations for parameters in set_target_temperature method enhance clarity and type safety.


364-364: Type annotations for parameters in set_swing method enhance clarity and type safety.


370-370: Method set_customize correctly handles JSON parsing and updates internal state based on customization parameters.

midealocal/devices/ac/message.py (17)

28-30: Constructor for MessageACBase now includes type annotations, enhancing type safety.


54-54: Constructor for MessageQuery now includes type annotations, enhancing type safety.


89-89: Constructor for MessagePowerQuery now includes type annotations, enhancing type safety.


108-108: Constructor for MessageToggleDisplay now includes type annotations, enhancing type safety.


145-145: Constructor for MessageNewProtocolQuery now includes type annotations, enhancing type safety.


170-172: Constructor for MessageSubProtocol now includes type annotations, enhancing type safety.


211-211: Constructor for MessageSubProtocolQuery now includes type annotations, enhancing type safety.


220-220: Constructor for MessageSubProtocolSet now includes type annotations, enhancing type safety.


301-301: Constructor for MessageGeneralSet now includes type annotations, enhancing type safety.


390-390: Constructor for MessageNewProtocolSet now includes type annotations, enhancing type safety.


477-477: Constructor for XA0MessageBody now includes type annotations, enhancing type safety.


499-499: Constructor for XA1MessageBody now includes type annotations, enhancing type safety.


521-521: Constructor for XBXMessageBody now includes type annotations, enhancing type safety.


548-548: Constructor for XC0MessageBody now includes type annotations, enhancing type safety.


589-589: Constructor for XC1MessageBody now includes type annotations, enhancing type safety.


656-656: Constructor for XBBMessageBody now includes type annotations, enhancing type safety.


713-713: Constructor for MessageACResponse now includes type annotations, enhancing type safety.

@rokam rokam merged commit c661480 into midea-lan:main Jun 4, 2024
3 checks passed
@chemelli74 chemelli74 deleted the chemelli74-typing-devices branch June 4, 2024 19:47
@linkser
Copy link

linkser commented Jul 28, 2024

这个版本make_message_uniq_set修改为make_message_set,导致风管机无法控制
ac.set_attribute("mode", 2) #did not work

型号:KFR-72T2/B3DN1-MXP(1)

message:{'header': 'aa3aac00000000000805', 'body': 'bb3000ffff12010000000000000000000000000000000000000000000000000000000000000000000000000000000000', 'message type': '.05', 'body type': '.bb'}

_used_subprotocol=True

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

Successfully merging this pull request may close these issues.

5 participants