-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Report data file errors in more detail #1782
base: master
Are you sure you want to change the base?
Report data file errors in more detail #1782
Conversation
4c63e61
to
49fcc01
Compare
8cdb7d8
to
a6beae3
Compare
Thanks for doing this. I would like to include the "coverage combine" message only if there are combinable data files. I've included other comments in the diff. |
for filename in combinable_files(data_file): | ||
print("-----") | ||
debug_data_file(filename) | ||
with suppress(NoDataFilesFoundError): |
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.
Why do we need to suppress this error 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.
We do not, but I tried to limit how many outputs I changed. Would you like this to display a friendly error instead?
@@ -317,7 +317,9 @@ def report(self, morfs: Iterable[TMorf] | None) -> float: | |||
file_be_gone(os.path.join(self.directory, ftr.html_filename)) | |||
|
|||
if not have_data: | |||
raise NoDataError("No data to report.") | |||
raise DataFileOrDirectoryNotFoundError.new_for_data_file_or_directory( | |||
os.path.dirname(self.coverage.get_data().base_filename()) |
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 have to think through whether the message here is correct. Is it always that the file doesn't exist?
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's good that the exceptions centralize the messages, but everywhere this exception is created it uses the same fairly complex expression. Can we centralize that as well?
tests/test_api.py
Outdated
with pytest.raises( | ||
NoDataError, | ||
match=( | ||
r"^The data file or directory `(.+?)` could not be found\. Perhaps `coverage " |
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.
"The data file or directory" seems odd to me. Don't we know whether we are expecting a file or directory?
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.
These results depend on the paths entered in the CLI. As far as I understand the code these are allowed to be data file paths or paths to directories containing data files. If the path does not exist, I'm not sure we would know if the user meant a file or a directory.
…ths, and make helpful suggestions
a6beae3
to
8bf5006
Compare
This PR fixes #1781
Changes
NoDataError
subclasses for specific purposes