Skip to content

Use operator specific messaging in division by zero diagnostics#13588

Merged
zanieb merged 1 commit intomainfrom
zb/div-zero-msg
Oct 1, 2024
Merged

Use operator specific messaging in division by zero diagnostics#13588
zanieb merged 1 commit intomainfrom
zb/div-zero-msg

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 ty 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!

@github-actions
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
@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

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants