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

Improve error message for chained comparisons #108

Open
AlexWaygood opened this issue Jan 19, 2022 · 3 comments
Open

Improve error message for chained comparisons #108

AlexWaygood opened this issue Jan 19, 2022 · 3 comments

Comments

@AlexWaygood
Copy link
Collaborator

AlexWaygood commented Jan 19, 2022

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

flake8-pyi/pyi.py

Lines 506 to 508 in 34c17bd

if len(node.comparators) != 1:
# mypy doesn't support chained comparisons
self.error(node, Y002)

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?

@hauntsaninja
Copy link
Collaborator

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.

@AlexWaygood
Copy link
Collaborator Author

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.

@JelleZijlstra
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants