-
Notifications
You must be signed in to change notification settings - Fork 9
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
Turn on typechecking in our GitHub CI #14
Merged
Merged
Conversation
This file contains 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
pniedzielski
added
bug
Something isn't working
enhancement
New feature or request
labels
Dec 8, 2023
We already typecheck the examples we bundle with the Python SDK. This patch turns on typechecking on the source code of the SDK as well, which is already has type annotations. Signed-off-by: Patrick M. Niedzielski <[email protected]>
The `Dict[K,V]` type is invariant in both `K` and `V`, so if `V1` is a subtype of `V2`, it isn’t the case that `Dict[K,V1]` is not a subtype of `Dict[K,V2]`. This patch changes type annotations from the concrete type `Dict` to the abstract base class `Mapping`, which is covariant in `V`, fixing some correct uses in our package that are mistakenly marked as incorrect by type checkers. Signed-off-by: Patrick M. Niedzielski <[email protected]>
This function looks up the name of the Python script, so as to provide it to the `NativeSession` as an identifier. We guard the use of this name with a `getattr` conditional, but the typechecker cannot determine that this forces it to be non-`None`, so this patch adds an additional `assert` which never fires, but which the typechecker can understand to silence an error. Signed-off-by: Patrick M. Niedzielski <[email protected]>
Signed-off-by: Patrick M. Niedzielski <[email protected]>
Signed-off-by: Patrick M. Niedzielski <[email protected]>
Signed-off-by: Patrick M. Niedzielski <[email protected]>
The type annotation for `on_message`’s `messages` argument has been incorrect, and hasn’t matched the values that are being passed to it in tests. `on_message` performs a conversion from the BlazingMQ wire protocol identifiers for message property types, which are represented as `int`s, to the Python SDK’s message property type enumeration, which are Python objects. However, the type annotation incorrectly documented that this conversion had already taken place. This patch updates the type annotation and makes the code that does the conversion clearer. Signed-off-by: Patrick M. Niedzielski <[email protected]>
pniedzielski
force-pushed
the
typechecking
branch
from
December 8, 2023 19:54
5353ba1
to
f2e3c7a
Compare
hallfox
approved these changes
Dec 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We already typecheck our examples, but we haven't been checking that the type annotations we include in our main source code are correct. This PR first turns on this type checking in our CI, and then fixes issues that the typechecker catches.
Closes: #6