-
Notifications
You must be signed in to change notification settings - Fork 38
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
Feature/clean typing linter #285
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR and effort, wil check out/review this weekend |
OK. Fixed those ones and others. 👍 |
Great, wasn't able to finish the review this weekend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @julesxxl.
I've added feedback and questions as they arose.
Once they have been processed I will run this version locally and do a final lookover.
Keep up the good work :)
config = dict(self.config_entry.options) | ||
user_input.pop(CONF_RESCAN, None) | ||
if user_input: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO's run this locally and go through config flow
@@ -75,100 +76,111 @@ def __init__(self, length=1, read_length=None): | |||
|
|||
|
|||
class EntityType: | |||
"""Base entityType.""" | |||
"""Base entity_type.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EntityType is an class here and should therefore not be renamed in the comment from class style to var style
super().__init__(entity_type_name=entity_type_name) | ||
|
||
|
||
class GenericAlarmLedger(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this removed elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed from line 180 probably due to the use of class on 166 and needing to be declared before used
@@ -207,7 +211,7 @@ class generic_alarm_ledger(Enum): | |||
"grid_L3_energy_reverse": RegisterInfo( | |||
2608, UINT16, UnitOfEnergy.KILO_WATT_HOUR, 100 | |||
), | |||
"grid_serial": RegisterInfo(2609, STRING(7)), | |||
"grid_serial": RegisterInfo(2609, str(STRING(7))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cast the string as an str here?
), | ||
"battery_error": RegisterInfo( | ||
register=1283, dataType=UINT16, entityType=TextReadEntityType(battery_error) | ||
"BatteryError": RegisterInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use batteryError here since generic Alarm ledger doesn't do the same as the battery error enum class
first_register = next(iter(registerInfoDict)) | ||
return registerInfoDict[first_register].register | ||
first_register = next(iter(register_infoDict)) | ||
return register_infoDict[first_register].register |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the name be register_info_dict to conform to convention?
if self.description.key: | ||
full_key = str(self.description.slave) + "." + self.description.key | ||
else: | ||
full_key = str(self.description.slave) + "." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this returns an invalid entity_id.
from typing import Any | ||
|
||
|
||
class PopBuffer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignored in review as it is still being written
@@ -120,7 +123,7 @@ def determine_victron_device_class(name, unit): | |||
SensorDeviceClass.VOLUME_STORAGE | |||
) # Perhaps change this to water if only water is measured in volume units | |||
if unit in [member.value for member in UnitOfSpeed]: | |||
if "meteo" in name: | |||
if name and "meteo" in name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add seperate check for name to exist and not check 2 times in different if statements.
self._attr_native_value = self.entity_type.decodeEnum( | ||
if data in { | ||
item.value # type: ignore[union-attr] | ||
for item in self.entity_type.entity_type_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has the decode enum been replaced?
That was not easy... So no more errors with ruff check, ruff format, mypy. But there are the TODOs with pylint and two other problems.
Unfortunately, I didn't get it work in HA. Pfff... Anyway, the code is there and since it's not urgent, we'll have to understand what's wrong... So many changes...
(I rebased onto #281.)
Errors in the logs: