Skip to content

Commit fc72660

Browse files
joke1196sonartech
authored andcommitted
SONARPY-3388: Add 314 to the supported Python versions (#559)
GitOrigin-RevId: e27a36ee102c2d84c0461a370f7eba648c6e8930
1 parent 640d858 commit fc72660

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

python-commons/src/test/java/org/sonar/plugins/python/IPynbSensorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ void test_python_version_parameter() {
174174

175175
PythonInputFile inputFile = inputFile(FILE_1);
176176
activeRules = new ActiveRulesBuilder().build();
177-
context.setSettings(new MapSettings().setProperty("sonar.python.version", "3.13"));
177+
context.setSettings(new MapSettings().setProperty("sonar.python.version", "3.14"));
178178
PythonIndexer pythonIndexer = pythonIndexer(List.of(inputFile));
179179

180180
sensor(pythonIndexer).execute(context);
181181

182-
assertThat(ProjectPythonVersion.currentVersions()).containsExactly(PythonVersionUtils.Version.V_313);
182+
assertThat(ProjectPythonVersion.currentVersions()).containsExactly(PythonVersionUtils.MAX_SUPPORTED_VERSION);
183183
}
184184

185185
private IPynbSensor notebookSensor() {

python-commons/src/test/java/org/sonar/plugins/python/PythonSensorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,9 @@ void test_python_version_parameter_no_warning() {
758758

759759
activeRules = new ActiveRulesBuilder().build();
760760

761-
context.setSettings(new MapSettings().setProperty("sonar.python.version", "3.13"));
761+
context.setSettings(new MapSettings().setProperty("sonar.python.version", "3.14"));
762762
sensor().execute(context);
763-
assertThat(ProjectPythonVersion.currentVersions()).containsExactly(PythonVersionUtils.Version.V_313);
763+
assertThat(ProjectPythonVersion.currentVersions()).containsExactly(PythonVersionUtils.MAX_SUPPORTED_VERSION);
764764
assertThat(logTester.logs(Level.WARN)).doesNotContain(PythonSensor.UNSET_VERSION_WARNING);
765765
verify(analysisWarning, times(0)).addUnique(PythonSensor.UNSET_VERSION_WARNING);
766766
}

python-frontend/src/main/java/org/sonar/plugins/python/api/PythonVersionUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_311;
2727
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_312;
2828
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_313;
29+
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_314;
2930
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_38;
3031
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_39;
3132

@@ -37,7 +38,8 @@ public enum Version {
3738
V_310(3, 10, "310"),
3839
V_311(3, 11, "311"),
3940
V_312(3, 12, "312"),
40-
V_313(3, 13, "313");
41+
V_313(3, 13, "313"),
42+
V_314(3, 14, "314");
4143

4244
private final int major;
4345
private final int minor;
@@ -75,7 +77,7 @@ public String toString() {
7577
}
7678

7779
private static final Version MIN_SUPPORTED_VERSION = V_38;
78-
public static final Version MAX_SUPPORTED_VERSION = V_313;
80+
public static final Version MAX_SUPPORTED_VERSION = V_314;
7981

8082
/**
8183
* Note that versions between 3 and 3.8 are currently mapped to 3.8 because
@@ -95,7 +97,8 @@ public String toString() {
9597
Map.entry("3.10", V_310),
9698
Map.entry("3.11", V_311),
9799
Map.entry("3.12", V_312),
98-
Map.entry("3.13", V_313));
100+
Map.entry("3.13", V_313),
101+
Map.entry("3.14", V_314));
99102
private static final Logger LOG = LoggerFactory.getLogger(PythonVersionUtils.class);
100103
public static final String PYTHON_VERSION_KEY = "sonar.python.version";
101104

python-frontend/src/test/java/org/sonar/plugins/python/api/PythonVersionUtilsTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_311;
3131
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_312;
3232
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_313;
33+
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_314;
3334
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_39;
3435
import static org.sonar.plugins.python.api.PythonVersionUtils.Version.V_38;
3536

@@ -38,7 +39,7 @@ class PythonVersionUtilsTest {
3839
@RegisterExtension
3940
public LogTesterJUnit5 logTester = new LogTesterJUnit5().setLevel(Level.DEBUG);
4041

41-
private static final List<PythonVersionUtils.Version> allVersions = List.of(V_38, V_39, V_310, V_311, V_312, V_313);
42+
private static final List<PythonVersionUtils.Version> allVersions = List.of(V_38, V_39, V_310, V_311, V_312, V_313, V_314);
4243

4344
@Test
4445
void supportedVersions() {
@@ -47,19 +48,19 @@ void supportedVersions() {
4748
assertThat(PythonVersionUtils.fromString("2.7")).hasSameElementsAs(allVersions);
4849
assertThat(PythonVersionUtils.fromString("2")).hasSameElementsAs(allVersions);
4950
assertThat(PythonVersionUtils.fromString("3")).hasSameElementsAs(allVersions);
50-
assertThat(PythonVersionUtils.fromString("3.9, 3.10")).containsExactlyInAnyOrder(V_39, V_310);
51+
assertThat(PythonVersionUtils.fromString("3.9, 3.10, 3.14")).containsExactlyInAnyOrder(V_39, V_310, V_314);
5152
assertThat(PythonVersionUtils.fromString("2.7, 3.9")).hasSameElementsAs(allVersions);
5253
assertThat(PythonVersionUtils.fromString("3.10")).containsExactlyInAnyOrder(V_310);
5354
}
5455

5556
@Test
5657
void version_out_of_range() {
57-
assertThat(PythonVersionUtils.fromString("4")).containsExactlyInAnyOrder(V_313);
58-
assertThat(logTester.logs(Level.WARN)).contains("No explicit support for version 4. Python version has been set to 3.13.");
58+
assertThat(PythonVersionUtils.fromString("4")).containsExactlyInAnyOrder(V_314);
59+
assertThat(logTester.logs(Level.WARN)).contains("No explicit support for version 4. Python version has been set to 3.14.");
5960
assertThat(PythonVersionUtils.fromString("1")).hasSameElementsAs(allVersions);
6061
assertThat(logTester.logs(Level.WARN)).contains("No explicit support for version 1. Support for Python versions prior to 3 is deprecated.");
61-
assertThat(PythonVersionUtils.fromString("3.14")).containsExactlyInAnyOrder(V_313);
62-
assertThat(logTester.logs(Level.WARN)).contains("No explicit support for version 3.14. Python version has been set to 3.13.");
62+
assertThat(PythonVersionUtils.fromString("3.15")).containsExactlyInAnyOrder(V_314);
63+
assertThat(logTester.logs(Level.WARN)).contains("No explicit support for version 3.15. Python version has been set to 3.14.");
6364
assertThat(PythonVersionUtils.fromString("3.12")).containsExactlyInAnyOrder(V_312);
6465
}
6566

@@ -83,9 +84,11 @@ void isPythonVersionGreaterOrEqualThan() {
8384
assertFalse(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(), V_39));
8485
assertFalse(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(V_311, V_312), V_313));
8586
assertFalse(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(V_310, V_312), V_311));
87+
assertFalse(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(V_313, V_312), V_314));
8688
assertTrue(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(V_39), V_39));
8789
assertTrue(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(V_39, V_310), V_39));
8890
assertTrue(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(V_312, V_310), V_39));
91+
assertTrue(PythonVersionUtils.areSourcePythonVersionsGreaterOrEqualThan(Set.of(V_314), V_314));
8992
}
9093

9194
}

0 commit comments

Comments
 (0)