-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fixed bug in how PythonTA reports error messages when parsing config files #920
Fixed bug in how PythonTA reports error messages when parsing config files #920
Conversation
Pull Request Test Coverage Report for Build 5492948948
💛 - Coveralls |
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.
@sushimon good work. In addition to the comment I left, please provide information about the errors/problems you encountered when try to test this behaviour with the other reporter types.
5385a28
to
250d7b0
Compare
@sushimon okay great, you should investigate the JSONReporter error further. |
@sushimon oh and for the second issue, yeah you can look into that as well. Note that |
linter.set_reporter(current_reporter) | ||
|
||
if not is_any_file_checked: | ||
current_reporter = linter.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.
Let me know if updating current_reporter
is okay. My reasoning was that since we set up this linter using the same config file as the one on line 117, this is the same reporter, except it is guaranteed that the instances of Message
from the config file errors have been converted to NewMessage
instances.
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.
@sushimon yes this is great!
…ting-errors-in-parsing-config
448ab5b
to
1b643f2
Compare
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.
@sushimon great work!
linter.set_reporter(current_reporter) | ||
|
||
if not is_any_file_checked: | ||
current_reporter = linter.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.
@sushimon yes this is great!
Motivation and Context
When running
check_all
orcheck_errors
and using a config file that contains an unknown option value (e.g. invalid message code in the "disable" section), PythonTA crashes and no report is generated. This PR aims to prevent PythonTA from crashing in this manner.Your Changes
Description:
on_set_current_module
to infer afilepath
if none was provided.CHANGELOG.md
file to document this bugfix.JSONReporter
,ColorReporter
, andPlainReporter
print messages and added test cases to verify they correctly print/display the desired messages.Type of change (select all that apply):
Testing
check_all
using all four checkers and verified they all printed the expected reports.Questions and Comments (if applicable)
When testing, I initially wanted to use theJSONReporter
so I can easily check whether the target message id (W0012
) was being reported when usingcheck_all
. However, it would cause anAttributeError
saying that "AttributeError: 'Message' object has no attribute 'to_dict'". I also tried using thePlainReporter
andColorReporter
and it seems that the message idW0012
was not being reported even though it was being reported after switching to theHTMLReporter
.When using the
ColorReporter
orPlainReporter
, the code snippet shown is not necessarily the line in which the error occurs in the config file. It always seems to show the 3 lines of the config file regardless of it's actual location in the config file.48209d1
, the reporter will print the messages in the most recent config file parsed. In theory, there is a corner case where the default PythonTA config file may have an error, as well as the provided config, but these reporters will not show the error in the default config. In practice, I believe this shouldn't be a big deal because the most recent one checked should be the only one that could possibly contain an error (since I don't believe we will ship the default Python config file with errors).Checklist