-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(general): refactor SARIF output #4606
Conversation
|
||
def _create_rules(self) -> list[dict[str, Any]]: | ||
rule_idx = 0 | ||
rules: "list[dict[str, Any]]" = [] |
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 quoted typing necessary even if you imported annotations from __future__
?
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.
it is a bit faster to put into a string literal, I somehow got used to it, when I add complex type hints. But you are right it is not needed when using the __future__
import
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 dug the rabbit hole a bit further and found out that "list[dict[str, Any]]" != list[dict[str, Any]]
It seems to have no real effect on linting for now but may be worth changing it regardless (?)
https://stackoverflow.com/a/46458497/11918269
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.
and as the comment to the answer suggests, don't do that and use the proper function typing.get_type_hints()
>>> typing.get_type_hints(bad_foo) == typing.get_type_hints(good_foo)
True
😉
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.
🤯
print("\nWrote output in SARIF format to the file 'results.sarif'") | ||
except EnvironmentError as e: | ||
print("\nAn error occurred while writing SARIF results to file: results.sarif") | ||
print(f"More details: \n {e}") |
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.
shouldn't we use logging instead of print here?
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.
in general yes, this is especially used in our checkov action and there printing is a bit more clear to the user.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
Fixes #4600
Fixes #4585
Checklist: