flake8-pyi icon indicating copy to clipboard operation
flake8-pyi copied to clipboard

Improve error message for chained comparisons

Open AlexWaygood opened this issue 3 years ago • 3 comments

We currently have a very specific test for chained comparisons on lines 506-508:

https://github.com/PyCQA/flake8-pyi/blob/34c17bd7d847905aacf4705dfc95e25ab12ce432/pyi.py#L506-L508

However, we then give a generic error message:

"Y002 If test must be a simple comparison against sys.platform or sys.version_info"

If we split this off into its own error code, we could give a much more specific error message:

YXXX Chained comparisons are not supported by type-checkers

Thoughts?

AlexWaygood avatar Jan 19 '22 20:01 AlexWaygood

I'm okay with the current behaviour. To me "simple comparison" is clear enough and I can't see a good reason for selectively disabling only one of the two error codes.

hauntsaninja avatar Jan 19 '22 20:01 hauntsaninja

I can't see a good reason for selectively disabling only one of the two error codes.

Yes, you're right -- it probably doesn't deserve its own error code. In which case, maybe we could make the error message for that code more customisable?

It just seems a bit silly to me that there's a comment in the source code that gives more information about why the error's being emitted than the error message that's given.

AlexWaygood avatar Jan 19 '22 20:01 AlexWaygood

Yes, maybe we could give a different error message with the same code? Not sure if that goes against general flake8 conventions.

Anyway, I don't think this is too important as it's not something that happens commonly.

JelleZijlstra avatar Jan 19 '22 20:01 JelleZijlstra