-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[flake8-2020
] Fix diagnostic message for !=
comparisons (YTT201
)
#18293
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
[flake8-2020
] Fix diagnostic message for !=
comparisons (YTT201
)
#18293
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I get chatgpt to address my comments?
@@ -88,12 +88,23 @@ impl Violation for SysVersionCmpStr3 { | |||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version) | |||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info) | |||
#[derive(ViolationMetadata)] | |||
pub(crate) struct SysVersionInfo0Eq3; | |||
pub(crate) struct SysVersionInfo0Eq3 { | |||
op: CmpOp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a boolean saying if it's ==
or !=
. Took me a while to realise that the rule doesn't support other compare operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed!
@@ -246,7 +257,7 @@ pub(crate) fn compare(checker: &Checker, left: &Expr, ops: &[CmpOp], comparators | |||
{ | |||
if *n == 3 && checker.enabled(Rule::SysVersionInfo0Eq3) { | |||
checker.report_diagnostic(Diagnostic::new( | |||
SysVersionInfo0Eq3, | |||
SysVersionInfo0Eq3 { op: ops[0] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use operator @
in the let arm instead of retrieving it form ops[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed!
You can't, it doesn't support any kind of iteration. |
flake8-2020
] Fix diagnostic message for !=
comparisons (YTT201
)
Summary
Closes #18292.