Skip to content
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

Improve Error class #1882

Merged

Conversation

adamchainz
Copy link
Contributor

@adamchainz adamchainz commented Jun 19, 2024

  1. Lazily compute the traceback string, using traceback.format_exception(). It’s only used in the rare case that "traceback" is in the import_error_display attribute, so we can save that work and memory in the usual case.
  2. Add a nice __repr__, to help debug test failures that make assertions on Error objects. I had a few cases where tests failed with inscrutable messages from pytest like Left contains one more item: <import_export.results.Error object at 0x3173c8690>, and I needed to rerun the test with the debugger to inspect the inner exception.

@adamchainz adamchainz marked this pull request as draft June 19, 2024 10:47
1. Lazily compute the traceback string, using `traceback.format_exception()`. It’s only used in the rare case that `"traceback"` is in the `import_error_display` attribute.
2. Add a nice `__repr__`, to help debug test failures that make assertions on `Error` objects. I had a few cases where tests failed with inscrutable messages from pytest like `Left contains one more item: <import_export.results.Error object at 0x3173c8690>`, and I needed to rerun the test with the debugger to inspect the inner exception.
@adamchainz adamchainz marked this pull request as ready for review June 19, 2024 12:27
Copy link
Contributor

@matthewhegarty matthewhegarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks

@coveralls
Copy link

Coverage Status

coverage: 100.0%. remained the same
when pulling c4716a8 on adamchainz:improve_error_class
into 4fddf0e on django-import-export:main.

@coveralls
Copy link

Coverage Status

coverage: 100.0%. remained the same
when pulling 16136e3 on adamchainz:improve_error_class
into 5595178 on django-import-export:main.

@matthewhegarty matthewhegarty merged commit 7de0ad3 into django-import-export:main Jun 19, 2024
13 checks passed
@adamchainz adamchainz deleted the improve_error_class branch June 19, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants