Move Tuya type information classes to separate module#157958
Conversation
|
Hey there @tuya, @zlinoliver, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the Tuya integration's type information classes by moving them from models.py to a new dedicated type_information.py module. The changes improve code organization without altering functionality.
- Extracts TypeInformation classes and the
find_dpcodefunction into a new module - Renames
EnumTypeData→EnumTypeInformationandIntegerTypeData→IntegerTypeInformationfor consistency - Alphabetically orders the TypeInformation class definitions (Bitmap, Enum, Integer)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/tuya/type_information.py |
New module containing all TypeInformation classes (TypeInformation base, BitmapTypeInformation, EnumTypeInformation, IntegerTypeInformation), the type mappings dictionary, and find_dpcode function with overloads |
homeassistant/components/tuya/models.py |
Removed TypeInformation classes and find_dpcode function; added imports from new type_information module |
homeassistant/components/tuya/sensor.py |
Updated import to use EnumTypeInformation from type_information module instead of EnumTypeData from models |
homeassistant/components/tuya/number.py |
Updated import to use IntegerTypeInformation from type_information module instead of IntegerTypeData from models |
homeassistant/components/tuya/light.py |
Updated import and all references from IntegerTypeData to IntegerTypeInformation |
| _number: IntegerTypeData | None = None | ||
|
|
There was a problem hiding this comment.
The attribute is fully unused (missed in previous wrapper migration) - better to just remove it than update the import and the type name.
|
Thanks @jbouwh 👍 |
Proposed change
TypeInformationclasses and correspondingfind_dpcodefunction to separate moduleEnumTypeDatatoEnumTypeInformationIntegerTypeDatatoIntegerTypeInformationTypeInformationclasses in alphabetical order in the new module_numberin number platformNo functionnality changes - preliminary work for improving Tuya data validation.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: