-
-
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
Added typing to functions and improved docstrings to be more descriptive. #177
Added typing to functions and improved docstrings to be more descriptive. #177
Conversation
Thanks. |
I think it should be good now 👍 |
I read through the code again and made some small changes/fixes (ref: last two commits on this PR). These shouldn't break anything or throw any new warnings or errors. |
Great. |
Didn't know about mypy. Seems like a great tool! I'll look into it, thanks! 😄 |
Notable changes after using mypy:
|
tibber/__init__.py
Outdated
self.info = data | ||
self._process_price_info(self.info) | ||
else: | ||
# TODO: Error handling? |
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.
Do you think it's okay to just return None instead of overwriting self.info with a potential None value? Does this break any functionality? There are 2 other places where I've done this (3 in total)
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.
@Danielhiversen ^ The question is really: When a user fetches data, but it fails to get that information because of a request error, should the method return None, overwrite self.info with value None, or should an exception be raised?
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.
return None is ok for this pr
Have you tested your changes locally? |
Yep! The only workflow I could not get to run was the isort workflow. I don't think that's a problem with the repo however, but rather on my side...
|
Running |
I actually double-checked and just realised that the tests are being skipped because pytest-asyncio is not installed... The third test then fails because at |
I added a new dependency (pytest-asyncio) so that the tests could be run and not just be skipped (see issue #178). There were some issues with the cache so the setup of the workflow failed. Therefore removed the caching step and used python-setup's built-in caching feature instead. This required a requirements.txt to install from afaik, so I added that. In short, the last changes done in this PR will fix #178. |
I could revert these last changes (requirements.txt and pytest-asyncio) and add them in a different PR if you'd like. Shall I do that? |
Fixed by #181 |
Not sure why pylint did not use the setup.cfg in this branch, but it worked fine in the master branch... Anyway, I fixed it by shortening the line 👍 |
Added typing to all the functions and parameters in
__init__.py
. Also added Sphinx-styled documentation to explain the parameters of the functions.