-
-
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
add type hints #42
add type hints #42
Conversation
@@ -7,54 +7,62 @@ | |||
|
|||
import json | |||
import os | |||
from typing import Any, Dict, List, Mapping, Optional, Tuple, TypeVar |
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 would recommend this be treated as a patch, as the underlying functionality hasn't changed, although a minor update would make sense too given the addition of a dependency.
Thanks for your contribution! I'll review and test the changes in the beginning of next week. No worries about the workflow fail. I may replace the current workflow anyway before a new release. |
I reviewed the code and it looks good to me. Thanks for your effort so far! The tests are running, but a mypy check returned some errors. Would you look into these?
|
@yaph I've handled the remaining mypy errors by loosening the type hints a bit for the helpers in 01e8341 and by defining specific function overloads for
The new function overloads also make the usage of |
Sounds good! fwiw I would expect that adding a |
Thanks so much for your work @jicruz96! While there are no breaking changes for the end user, I'll create a new major release soon. |
closes #41
Changes
geonamescache.types
usingtyping.TypedDict
typing-extensions
added as package dependency to ensure type hints work for all Python versions >=3.6*This will offer a more user-friendly experience in IDEs, including auto-complete and type checking (if the user has configured these).
Notes
*If you do not want any dependencies added to the package, I can provide an alternate PR
That alternate PR would use
sys.version_info
to check the python version before assigning types, and then use only thetyping
features available for each respective python version. I would ensure to support up to 3.8, and can support up to 3.6 if requested.On formatting:
There was no formatting or linting config beyond the .editorconfig, so I took my best guess with line breaks and line lengths.