Skip to content

fix[ux]: fix empty hints in error messages#4351

Merged
charles-cooper merged 12 commits intovyperlang:masterfrom
sandbubbles:fix/empty-hint
Nov 19, 2024
Merged

fix[ux]: fix empty hints in error messages#4351
charles-cooper merged 12 commits intovyperlang:masterfrom
sandbubbles:fix/empty-hint

Conversation

@sandbubbles
Copy link
Copy Markdown
Contributor

@sandbubbles sandbubbles commented Nov 6, 2024

What I did

Remove empty hint message from exceptions. As in #4313.

How I did it

Modify the check of absent hint to include an empty string.

How to verify it

Commit message

remove empty hint message from exceptions. this regression was
introduced in 03095ce3921636. the root cause of the issue, however,
was that `hint=""` could be constructed in the first place. this commit
fixes the `get_levenshtein_error_suggestions` helper so that it returns
`None` on failure to find a suggestion rather than the empty string
`""`.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@sandbubbles
Copy link
Copy Markdown
Contributor Author

UndeclaredException is the only place where I encountered empty hints. An alternative solution is to add the check there to prevent the hint from being an empty string in the first place.

@charles-cooper
Copy link
Copy Markdown
Member

It seems like a code smell that we are creating empty string hints in the first place. Do we know where they are coming from?

@sandbubbles
Copy link
Copy Markdown
Contributor Author

It seems like a code smell that we are creating empty string hints in the first place. Do we know where they are coming from?

I think its as in this - #4351 (comment) - just the UndeclaredException. But I can spend some more time if i encounter it elsewhere.

@charles-cooper
Copy link
Copy Markdown
Member

note the regression comes from #4154 -- the previous code checked for truthy value of self.hint.

@sandbubbles
Copy link
Copy Markdown
Contributor Author

sandbubbles commented Nov 7, 2024

note the regression comes from #4154 -- the previous code checked for truthy value of self.hint.

Yeah, I think there are two main solutions:

  1. Have the check in the same way as pre fix[ux]: fix empty hints in error messages #4351 - (which is proposed in this PR, because i though hint can be only None or string, but I can rewrite it to if not hint to keep the truthyness).
  2. Or keep the current test if hint is None and modify get_levenshtein_error_suggestions to return None instead of an empty string (which is used as the hint in one type of UndeclaredDefinition)

I think the second solution is cleaner, but the first solution ensures that we catch any missed empty string hints.
What do you prefer?

@charles-cooper
Copy link
Copy Markdown
Member

i think 2. is better -- we should not be supplying empty string as a hint!

@sandbubbles
Copy link
Copy Markdown
Contributor Author

i think 2. is better -- we should not be supplying empty string as a hint!

Hope its better now :)

@sandbubbles sandbubbles marked this pull request as ready for review November 9, 2024 09:55
@charles-cooper charles-cooper changed the title fix[ux]: empty hint fix[ux]: fix empty hints in error messages Nov 19, 2024
@charles-cooper charles-cooper enabled auto-merge (squash) November 19, 2024 17:54
@charles-cooper charles-cooper merged commit 7d54f32 into vyperlang:master Nov 19, 2024
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.

2 participants