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

[BUG] etype was dropped from traceback.format_exception_only in python 3.10+ #117

Closed
QMalcolm opened this issue Jul 13, 2023 · 0 comments · Fixed by #119
Closed

[BUG] etype was dropped from traceback.format_exception_only in python 3.10+ #117

QMalcolm opened this issue Jul 13, 2023 · 0 comments · Fixed by #119
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@QMalcolm
Copy link
Collaborator

QMalcolm commented Jul 13, 2023

We recently discovered that the named parameter etype of traceback.format_exception_only was dropped in python 3.10+. Currently we use the etype parameter in two places:

  1. the generate_exception_issue function
  2. the CumulativeMetricRule semantic validation

If either of these code paths are hit when one is using python 3.10+, then an exception like the following gets raised

  File "/Users/quigleymalcolm/Developer/dbt-labs/dbt-semantic-interfaces/dbt_semantic_interfaces/validations/validator_helpers.py", line 365, in wrapper
    generate_exception_issue(
  File "/Users/quigleymalcolm/Developer/dbt-labs/dbt-semantic-interfaces/dbt_semantic_interfaces/validations/validator_helpers.py", line 343, in generate_exception_issue
    f"{''.join(traceback.format_exception_only(etype=type(e), value=e))}",
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: format_exception_only() got an unexpected keyword argument 'etype'

This is extra problematic as the only way to work around the issue is to fix whatever is wrong with your config that is trying to raise a validation issue, but this exception ends up swallowing up the initial discovered problem 🙃

Solution

We could continue passing the type of the exception, as it's still accepted as a positional argument wherein it just has to be an unnamed argument and the first in the function call. However as of python 3.5, the exception type began being inferred from the passed in exception value. Since we only support python 3.8+, it seems like the best path forward would be to just drop the etype in the two linked calls.

@QMalcolm QMalcolm added bug Something isn't working good first issue Good for newcomers labels Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant