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

style[next]: standardize error messages. #1386

Merged
merged 11 commits into from
Dec 13, 2023
Merged

Conversation

DropD
Copy link
Contributor

@DropD DropD commented Dec 5, 2023

Description

  • add style guide to the coding guidelines
  • fix existing error messages in next
  • deal with ensuing qa errorrs / test updates
  • unshadow one test and fix the code it wasn't testing

Scope

The scope of this PR is purely the styling of existing error messages in gt4py.next.

Out of Scope

Refactoring exception types, automatically composing recurring types of error messages etc is explicitly deferred to future PRs.

Requirements

  • All fixes and/or new features come with corresponding tests.
  • Important design decisions have been documented in the approriate ADR inside the docs/development/ADRs/ folder.

@DropD DropD requested review from havogt and petiaccja December 5, 2023 14:41
CODING_GUIDELINES.md Outdated Show resolved Hide resolved
Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

I only reviewed the changes in the coding conventions document and they look good to me (just have some style suggestions typo fixes).

As an additional comment (probably outside of the scope of this PR), I think we should look into refactor a bit our code to add more custom exceptions in the places where it makes sense and also to make sure we catch internal exceptions and wrapped them into informative DSLErrors in all places visible to users.

CODING_GUIDELINES.md Outdated Show resolved Hide resolved
CODING_GUIDELINES.md Outdated Show resolved Hide resolved
CODING_GUIDELINES.md Outdated Show resolved Hide resolved
CODING_GUIDELINES.md Outdated Show resolved Hide resolved
Co-authored-by: Enrique González Paredes <[email protected]>
@DropD
Copy link
Contributor Author

DropD commented Dec 8, 2023

I only reviewed the changes in the coding conventions document and they look good to me (just have some style suggestions typo fixes).

As an additional comment (probably outside of the scope of this PR), I think we should look into refactor a bit our code to add more custom exceptions in the places where it makes sense and also to make sure we catch internal exceptions and wrapped them into informative DSLErrors in all places visible to users.

Out of scope for this PR but not for the project. Expect another PR along those lines.

@@ -1108,7 +1108,7 @@ def unpack(
def test_tuple_unpacking_too_many_values(cartesian_case):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was previously shadowed by the succeeding one (now renamed), and turned out to fail. The changes to foast_passes.type_deduction are to make this one pass.

Comment on lines -365 to +369
if not any(isinstance(i, tuple) for i in indices) and len(indices) != num_elts:
if not any(isinstance(i, tuple) for i in indices) and len(targets) != num_elts:
raise errors.DSLError(
node.location, f"Too many values to unpack (expected {len(indices)})."
node.location, f"Too many values to unpack (expected {len(targets)})."
Copy link
Contributor Author

@DropD DropD Dec 8, 2023

Choose a reason for hiding this comment

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

These changes make the test for the failure mode of too many values pass. Compare #1386 (comment).

@DropD DropD requested a review from havogt December 8, 2023 10:28
Copy link
Contributor

@havogt havogt left a comment

Choose a reason for hiding this comment

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

Thanks, looks good.

@DropD DropD merged commit a5b2450 into GridTools:main Dec 13, 2023
27 checks passed
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.

3 participants