Skip to content
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

Add more type hints, fix some pylint warnings #71

Merged
merged 4 commits into from
Apr 11, 2021

Conversation

KapJI
Copy link
Collaborator

@KapJI KapJI commented Apr 11, 2021

Mypy helps to catch places where Optional is not handled properly.

Fixes #66

@KapJI KapJI added the refactoring Refactoring label Apr 11, 2021
@KapJI KapJI requested a review from leikoilja April 11, 2021 17:14
Comment on lines +291 to +294
access_token = self.get_access_token()
if not access_token:
LOGGER.debug("%s Unable to obtain access token.", log_prefix)
return None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should extract that check into a helper function decorator or just a helper function to call at all places as we do now

Copy link
Owner

@leikoilja leikoilja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, those are some really good changes 💯

pyproject.toml Show resolved Hide resolved
Comment on lines +57 to +59
good-names = [
"zc",
]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that for? 🤔

Copy link
Collaborator Author

@KapJI KapJI Apr 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix invalid-name pylint warning in ServiceListener methods. This allows zc as a valid name.

tests/test_client.py Show resolved Hide resolved
@@ -279,6 +280,7 @@ def test_get_homegraph(
self.assertEqual(m_get_home_graph_request.call_count, 1)

# Expired homegraph
assert self.client.homegraph_date is not None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have here unittest pattern, just to have it consistent with the rest of the code?

Suggested change
assert self.client.homegraph_date is not None
self.assertIsNotNone(self.client.homegraph_date)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, mypy can't narrow type from such calls: python/mypy#4063

@KapJI KapJI merged commit 8b572bd into leikoilja:master Apr 11, 2021
@KapJI KapJI deleted the more-types branch April 11, 2021 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move pylint exclude to pyproject
2 participants