-
-
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
Add new JSON reporter #8929
Add new JSON reporter #8929
Conversation
@jacobtylerwalls Is the issue on |
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.
Some preliminary comments, I'll do a more thorough review later (I'm on mobilel) I had only a quick look but nothing seems to be wrong
pylint/lint/base_options.py
Outdated
@@ -103,7 +103,7 @@ def _make_linter_options(linter: PyLinter) -> Options: | |||
"short": "f", | |||
"group": "Reports", | |||
"help": "Set the output format. Available formats are text," | |||
" parseable, colorized, json and msvs (visual studio)." | |||
" parseable, colorized, json2 and msvs (visual studio)." |
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 don't think we should hide the fact that the json reporter still exists, generating this text would be nice too imo.
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 guess we have a different opinion here then.
I think there should be one way to do things and that json2
is superior. Thus, that option is what we should advertise to users looking through the possibilities.
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.
Yes, but imagine you maintain a tool that consumes the old reporter. And you're reviewing a PR, and you need to brush up on the context. You come here, and it's gone. Won't you burn time trying to figure out what happened and wondering why things aren't horribly broken?
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.
Isn't that what the changelog is for? If you search for json
you'll find the change.
I'm fine with adding something like json (deprecated)
but as expressed elsewhere I would really like to nudge all users to the new reporter.
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.
Yeah I'm waffling on this one. As long as it's somewhere I guess it doesn't have to be in the CLI help.
This comment has been minimized.
This comment has been minimized.
I don't know, I'd appreciate help investigating.
From recent experience, no, nothing about package layouts without |
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.
Big thanks for picking this up!
pylint/lint/base_options.py
Outdated
@@ -103,7 +103,7 @@ def _make_linter_options(linter: PyLinter) -> Options: | |||
"short": "f", | |||
"group": "Reports", | |||
"help": "Set the output format. Available formats are text," | |||
" parseable, colorized, json and msvs (visual studio)." | |||
" parseable, colorized, json2 and msvs (visual studio)." |
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.
Yes, but imagine you maintain a tool that consumes the old reporter. And you're reviewing a PR, and you need to brush up on the context. You come here, and it's gone. Won't you burn time trying to figure out what happened and wondering why things aren't horribly broken?
My initial inclination is that we need a stronger reason to do this, but I'm not certain yet. Is there a reason we need to be this paranoid? Don't we anticipate never touching this again? |
After seeing the trouble Whenever somebody want to access something I'm highly in favour of making it public and creating a well-defined API for it, but I just don't want to deal with another spree of deprecation and removal issues. |
It it really necessary to add an underscore? Yes deprecations are quite a hassle, but it also has it's upsides. E.g. if users want to customize any of the existing reporters, they can easily subclass it. As long as it isn't documented publicly, it's just kindness / good responsibility of us not to break stuff unnecessarily. Another example, consider the |
If there is a need for it they can for it to become public and we can then make that explicit. For me using the underscores is also about setting expectations about what can and what can not change. I'm fine with maintaining a large public API, but only when we see a need for it because plugin writers or users ask for it. From the current state we are in we can only get there by making new code explicitly private.
Again, I think there is too much of a grey array there. There were quite a bit of number of functions that I would have liked to change or delete when doing the configuration rewrite and the typing stuff but which I couldn't. Some |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8929 +/- ##
=======================================
Coverage 95.74% 95.75%
=======================================
Files 173 173
Lines 18558 18592 +34
=======================================
+ Hits 17768 17802 +34
Misses 790 790
|
This comment has been minimized.
This comment has been minimized.
@@ -35,3 +35,4 @@ class Confidence(NamedTuple): | |||
|
|||
CONFIDENCE_LEVELS = [HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, UNDEFINED] | |||
CONFIDENCE_LEVEL_NAMES = [i.name for i in CONFIDENCE_LEVELS] | |||
CONFIDENCE_MAP = {i.name: i for i in CONFIDENCE_LEVELS} |
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 pains me to see that we're basically recreating the enum.Enum
interface for our 5 confidences constants and their 1 helper class and 3 helper constants. I don't think we should refactor but it does itch me every time.
pylint/reporters/_json_reporter.py
Outdated
evaluation, {}, {**counts_dict, "statement": stats.statement or 1} | ||
) | ||
except Exception as ex: # pylint: disable=broad-except | ||
score: str | int = f"An exception occurred while rating: {ex}" |
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.
We can mock an exception in the score evaluation in order to get coverage, or maybe provide a bad string via config that will create an error ?
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 I agree with Marc that we should prefer building new reporters like json3 if it ever came to that rather than make this private.
a4fcf2d
to
53a5835
Compare
I rebased and force pushed to remove the private making commits. This now only introduce a new reporter and uses it where necessary/possible. Let me know what you guys think! |
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 53a5835 |
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.
Look ready, it only needs the example of json in 3.0.md that Jacob suggested and let's merge 👍
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Type of Changes
Description
Closes #4741
Closes #3504
As discussed in the issue we create a new
json2
reporter that users can now use to get the score and other statistics. Since I want to keep being conscious about what is and isn't public API I decided to put both reporters in the private namespace. Since we are still in beta that should be fine? 😄