Fix test_checkstyle.py interpreter constraint #6983
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Right now,
test_checkstyle.py
relies on the assumption that we only allowCPython>=2.7,3
.The tests stop behaving as intended when allowing
CPython>=3.6<4
, as we will be doing in #6959. This is because the tests are testing how we handle a whitelist ofCPython>=3.6
, but when we allow this by default, the whitelist no longer matters because the linter will already be working with that interpreter.Solution
Constrain the test targets to
CPython>=3.4,<=3.5
, as we no longer support these Python 3 versions, yet they are still meaningful versions. When the whitelist is turned on, the tests will run the linter using either Python 3.4 or 3.5.Note that constraining to
CPython>=3.8
does not work, as Python 3.8 is not yet available so the tests white listing that interpreter will fail due to not finding a corresponding interpreter.Other solution attempted
I first tried to constrain
PythonSetup.global_instance().interpreter_constraints
to only allow Python 2.7, as we do now.I got the constraint to work, but the tests were still failing. I found that this is due to the function
PythonSetup.compatibility_or_constraints
, which no matter what uses the passed compatibility constraints when given, rather than first trying to read the target's compatibility. So, the Python 3 targets were improperly resolving as Python 2 compatible.