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

[red-knot] Enhancing Diagnostics for Compare Expression Inference #13819

Conversation

cake-monotone
Copy link
Contributor

Summary

  • Refactored comparison type inference functions in infer.rs: Changed the return type from Option to Result to lay the groundwork for providing more detailed diagnostics.
  • Updated diagnostic messages.

This is a small step toward improving diagnostics in the future.

Please refer to #13787

Test Plan

mdtest included!

Copy link
Contributor

github-actions bot commented Oct 19, 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! Not at all a full review, just a couple of nits I spotted while skimming

crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
crates/red_knot_python_semantic/src/types/infer.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Looks great! I just have one minor naming comment; I'll push that and then merge.

}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct OperatorUnsupportedError<'db> {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit: perhaps this should be called BinaryOperatorUnsupportedError, since there are also unsupported unary operations, but this error struct is only suitable for carrying information about a binary operator.

Copy link
Contributor

@carljm carljm Oct 19, 2024

Choose a reason for hiding this comment

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

Sorry, should be CompareOperatorUnsupportedError, since this is actually specific to ast.CmpOp. Or maybe for brevity could just be CompareUnsupportedError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it’s coming from the rule name
( https://github.com/astral-sh/ruff/pull/13819/files#diff-65c2c229c88f4021638c996a7496384000d9e7b53b08426b34e92f120bd30b06R2783)
But you're right, CompareUnsupportedError makes more sense! I think the rule name could be updated as well, but it’s a pretty minor thing.

@carljm carljm enabled auto-merge (squash) October 19, 2024 18:04
@carljm carljm merged commit fb66f71 into astral-sh:main Oct 19, 2024
19 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