[python] Compare versions of module SDKs in PythonLanguageLevelPusher using a stream

Even though LanguageLevel enum items are already sorted by the corresponding
version, I decided to introduce a dedicated comparator to make sure that the
logic of isOlderThan/isAtLeast is used for compareTo, not the default order of
enums.

GitOrigin-RevId: f1d4845154c9b71e920e2b634ea6339643bf9467
This commit is contained in:
Mikhail Golubev
2023-05-08 12:27:08 +03:00
committed by intellij-monorepo-bot
parent 8f10389294
commit 927eca19f5
2 changed files with 11 additions and 11 deletions

View File

@@ -8,6 +8,7 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -64,6 +65,10 @@ public enum LanguageLevel {
PYTHON311(311),
PYTHON312(312);
public static final Comparator<LanguageLevel> VERSION_COMPARATOR = (first, second) -> {
return first == second ? 0 : first.isOlderThan(second) ? -1 : 1;
};
/**
* This value is mostly bound to the compatibility of our debugger and helpers.
* You're free to gradually drop support of versions not mentioned here if they present too much hassle to maintain.