-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
test(rules): Improve type coverage #91849
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
Open
kcons
wants to merge
1
commit into
master
Choose a base branch
from
kcons/morespan
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21
−12
Open
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -667,7 +667,7 @@ def notify_sentry_app(event: GroupEvent, futures: Sequence[RuleFuture]): | |
|
||
# If the future comes from a rule with a UI component form in the schema, append the issue alert payload | ||
# TODO(ecosystem): We need to change this payload format after alerts create issues | ||
id = f.rule.id | ||
id: str | int = f.rule.id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# if we are using the new workflow engine, we need to use the legacy rule id | ||
# Ignore test notifications | ||
|
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
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.
cast should almost never be used. this indicates you're not properly typing something else somewhere.
in the exceedingly rare case cast should be used to work around a bug in the type checker -- but even then
# type: ignore
is preferred since it doesn't have runtime overhead like castwithout digging into it this seems like
RuleFuture
should have a generic type and perhaps a TypedDict for whatever thiskwargs
isThere 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 perhaps not ambitious enough here, just aiming to type the tupes so they weren't Any.
Hadn't thought to prefer type ignore over cast; I'd previously preferred
cast
since the cost isn't significant in most code and you don't end up with anAny
, but I guess if I'm not confident enough to throw in an assert,Any
might be more appropriate anyway.The real issue, as you note, is that I don't know how to properly type
RuleFuture
. By design, it's a kwargs that corresponds to whatever is expected by whatever function has been wrapped up in it. For most, it's None, for a couple (this is one) cases it has a dict of various values, but conceptually it's designed to be extensible.I imagine the proper approach, type-wise, if we want to serialize to a
dict[str, Any]
is to have some extraction and validation rather than assuming?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.
maybe
and then callers / users would use an appropriate
TypedDict
?