-
Notifications
You must be signed in to change notification settings - Fork 50
Feat: Adds type annotations #43
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d5be557
Initial annotations.
peterschutt 3058704
Fixes issues in `queue.py`.
peterschutt bfb918d
Undo altered import ordering.
peterschutt 82117a1
Removes unused import.
peterschutt 1b2114a
Convention `import typing as t`
peterschutt 85b571c
No string types.
peterschutt 769b061
No relative imports.
peterschutt 090282f
Fix for `Job.next_retry_delay()`.
peterschutt 59ed976
Narrowing Optional types.
peterschutt 4f27e81
Adds typing-extensions dependency.
peterschutt dc519fa
Review candidate.
peterschutt dc0cc9c
Run isort.
peterschutt b737b5a
Removes 3.7 support and adds 3.11.
peterschutt c31cdd6
3.11 now GA
peterschutt 14505db
Fixes for pyright public interface check tool.
peterschutt e9e10a8
Walk back obviously redundant typing.
peterschutt 08fe162
Timers arg to `Worker` doesn't need all keys.
peterschutt 5ffaffe
Merge remote-tracking branch 'upstream/master' into type-annotations
peterschutt 638c136
Includes `py.typed` in distribution.
peterschutt 728bd2c
Adds `__all__` for explict reexport of top level names.
peterschutt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include setup.py | ||
include README.md | ||
include LICENSE | ||
include saq/py.typed | ||
recursive-include saq/static * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[mypy] | ||
show_error_codes = True | ||
disallow_untyped_defs = True | ||
check_untyped_defs = True | ||
warn_redundant_casts = True | ||
warn_unreachable = True | ||
warn_unused_ignores = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this syntax legal in 3.7?
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 was just about to write an explanation.
The
from __future__ import annotations
means that all annotations are strings at runtime, so no runtime errors irrespective of version, and type checkers are able to use the current syntax irrespective of the version.I've been running the tests locally on 3.8 without issue and that syntax was introduced in 3.10. Similarly, the builtin subscription syntax, e.g.,
list[...]
is 3.9+ but the future annotations mean we don't need to worry about the runtime errors.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.
Of course, if there is an issue I'm missing here, or you'd prefer to stay syntactically valid with the min version irrespective of the future annotations, I'll be happy to roll them back. Just that the current syntax is a lot nicer than what was available in 3.7.
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 think mypy will automatically add an Optional type when the default value is None? I could have that wrong, though.
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.
You are correct, but reliance on it is discouraged: python/peps#689 and python/mypy#9091