pylint icon indicating copy to clipboard operation
pylint copied to clipboard

The messages `E0106` and `W1502` seem to be unreachable

Open ruancomelli opened this issue 1 year ago • 2 comments

Question

The messages E0106: return-arg-in-generator and W1502: boolean-datetime seem to be unreachable, i.e., there is no way to trigger them currently.

The main reason behind this is that the maximum and minimum versions for emitting messages are compared to sys.version_info: https://github.com/PyCQA/pylint/blob/e666506158feab03630c37dfb9bf9fd498f7a52a/pylint/message/message_definition.py#L73-L79 and, since pylint requires Python >= 3.7, sys.version_info is always greater than or equal to (3, 7). Hence, we can never satisfy maxversion for those two checkers.

The configuration option py-version should probably be taken into account here, but that does not seem to happen at the moment.

Related to this, but possibly a different issue: since pylint is taking the current runtime instead of py-version to run the checkers, the check sys.version_info[:2] == (3, 5) in AsyncChecker would be always false, and can probably be removed: https://github.com/PyCQA/pylint/blob/2b7556aefac48b41dacdd2e852cdf1e05f0daf88/pylint/checkers/async.py#L50

Documentation for future user

As "expected behaviour", either the py-version option should be used to decide if a message may be emitted or not, or those messages should be removed.

I would be happy to contribute in both cases :smile:

Additional context

I am not sure what is the correct type for this issue. I chose "question" because it did not seem to fit as a bug report or as an enhancement proposal - sorry if I got it wrong.

I initially reported this on Discord and was requested to open an issue here.

ruancomelli avatar Sep 21 '22 14:09 ruancomelli

Both of those should probably take py-version into account. It is quite recent addition so it makes sense that older checkers don't make use of that config yet.

Both should probably be tackled in their own issue and PR to make review easier. Would you mind opening a new issue for the second issue? I think the bug template makes the most sense here.

DanielNoord avatar Sep 21 '22 14:09 DanielNoord

Thank you @ruancomelli, great catch and well detailed issue.

Pierre-Sassoulas avatar Sep 21 '22 18:09 Pierre-Sassoulas

I think this issue may have been resolved by https://github.com/PyCQA/pylint/pull/7580 ?

clavedeluna avatar Nov 03 '22 20:11 clavedeluna

Great catch @clavedeluna, we choose to use py-version in may_be_emitted in #7580 so the error is now reachable with the right py-version and I'm going to close.

Pierre-Sassoulas avatar Nov 04 '22 08:11 Pierre-Sassoulas