Closed zxdavb closed 5 years ago
I think a few more things are needed:
base.py
isn't necessarily complete - I will reviewif self.refresh_token is None:
)raise EvohomeClientInvalidPostData()
After commit 0a034db:
(hass) dbonnes@vm-builder:~/evohome-client/evohomeclient2$ flake8 *.py --ignore=E501
(hass) dbonnes@vm-builder:~/evohome-client/evohomeclient2$ pylint *.py --disable=C0301
************* Module evohomeclient2.controlsystem
controlsystem.py:21:2: W0511: TODO: is systemId set via self.__dict__.update(local_data)? (fixme)
controlsystem.py:10:0: R0902: Too many instance attributes (8/7) (too-many-instance-attributes)
************* Module evohomeclient2
__init__.py:39:4: R0913: Too many arguments (7/5) (too-many-arguments)
------------------------------------------------------------------
Your code has been rated at 9.91/10 (previous run: 9.89/10, +0.03)
Argh! client.locations[0]._gateways[0]._control_systems[0].zones
has two copies of every zone!
And I can't work out why! OK, I was stupid.
Fixed now.
So the good news is that chasing this bug required me to make extensive use of refresh_token
s and access_tokens
on my HomeAssistant component - they performed flawlessly.
Lots of stuff:
Added some additional logging.
Removed
base.py
altogether; this required a bit of refactoring.Minor improvements to docstrings, including PEP-257.
As a rule, moved lint-hints out to column 81 to distinguish them from comments.
Removed superfluous code, such as the
if
conditional:Minor improvements to code (e.g. A=B=None, instead of A=None, and B=None).
Removed unneeded wrappers, e.g.:
self.client._convert(response.text)
becomesresponse.json()
.Fix dodgy
super()
s.Fixes a potential bug, (e.g.
access_token == ''
):becomes
BTW,
not (self.access_token and self.access_token_expires)
is more concise, but the above reads better.