custom-components / climate.programmable_thermostat

Programmable thermostat that let you have a smart thermostat on budget.
The Unlicense
115 stars 35 forks source link

Flow #64

Closed mdeweerd closed 9 months ago

mdeweerd commented 1 year ago

You can run

pip3 install pre-commit
# To identify potential issues:
pre-commit run -a pylint
pre-commit run -a mypy
# To format the code:
pre-commit run -a 

And you should check the hacs action to at least fix the manifest.json errors .

mdeweerd commented 1 year ago

I managed to get pre-commit to run in the ci-yml setup (run manually at this time) : https://github.com/mdeweerd/climate.programmable_thermostat/actions/runs/4324555651/jobs/7549596498 .

You can get the same output by running pre-commit locally.

Several messages should be attended to.

It's not obvious that these corrections will solve #44 , but they'll help avoid/fix other errors at least.

I am not using this component, so there is nothing more I will do with regards to it.

MapoDan commented 1 year ago

Ciao, I was off for a very long period and I was looking now at your pull request. Since I'm not an expert at all, can you clarify better to me what your changes will do and how should it solve the reload service issue?

Thanks Daniele

mdeweerd commented 1 year ago

Hi Daniele 'pre-commit' is basically a tool to run other tools - generally upon commit.

These other tools help improve code quality. Some of the will format the code, others are there to identify potential issues.

Possibly the issue leading up to the reload issue is identified by these tools.

For instance: custom_components/programmable_thermostat/climate.py:143:72: E711 comparison to None should be 'if cond is None:' refers to a line such as https://github.com/custom-components/climate.programmable_thermostat/blob/90eae77c99dc8e8adf387de3b6030561b27a08b5/custom_components/programmable_thermostat/climate.py#L132 which is not properly testing if variables are set to None - the result of such a test may not provide the desired effect in the code.

The message custom_components/programmable_thermostat/config_flow.py:50:48: B006 Do not use mutable data structures for argument defaults. They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.

refers to something like

https://github.com/custom-components/climate.programmable_thermostat/blob/90eae77c99dc8e8adf387de3b6030561b27a08b5/custom_components/programmable_thermostat/config_flow.py#L174

While initializer/default is '{}', it looks as if this default value will be the empty hash on every call. However, it will actually reuse the new value on the next call. So if this empty default hash gets values during the method's execution, the next execution (with the default value) will start with a non empty list.

That second example concerns the config_flow, so that could potentially be related to the reload issue.