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

Use operator specific messaging in division by zero diagnostics #13588

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Oct 1, 2024

Requested at #13576 (comment)

@zanieb zanieb requested a review from carljm as a code owner October 1, 2024 12:39
@zanieb zanieb added the red-knot Multi-file analysis & type inference label Oct 1, 2024
"Cannot divide object of type 'Literal[2]' by zero.",
"Cannot divide object of type 'Literal[3]' by zero.",
"Cannot floor divide object of type 'Literal[2]' by zero.",
"Cannot reduce object of type 'Literal[3]' modulo zero.",
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the most consistent language I can find for this online.

Copy link
Member

Choose a reason for hiding this comment

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

could possibly do something like this, but it's annoyingly verbose:

Suggested change
"Cannot reduce object of type 'Literal[3]' modulo zero.",
"Using modulo with a zero divisor is undefined on an object of type 'Literal[3]'.",

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that seems too verbose to me and differs quite a bit from the other messages.

Copy link
Member

Choose a reason for hiding this comment

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

I think what you have now is fine!

Copy link
Contributor

github-actions bot commented Oct 1, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you!!

"Cannot divide object of type 'Literal[2]' by zero.",
"Cannot divide object of type 'Literal[3]' by zero.",
"Cannot floor divide object of type 'Literal[2]' by zero.",
"Cannot reduce object of type 'Literal[3]' modulo zero.",
Copy link
Member

Choose a reason for hiding this comment

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

could possibly do something like this, but it's annoyingly verbose:

Suggested change
"Cannot reduce object of type 'Literal[3]' modulo zero.",
"Using modulo with a zero divisor is undefined on an object of type 'Literal[3]'.",

@zanieb zanieb merged commit cfd5d63 into main Oct 1, 2024
20 checks passed
@zanieb zanieb deleted the zb/div-zero-msg branch October 1, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants