diff --git a/python/helpers/pip-9.0.3.tar.gz b/python/helpers/pip-9.0.3.tar.gz deleted file mode 100644 index b96065ab2820..000000000000 Binary files a/python/helpers/pip-9.0.3.tar.gz and /dev/null differ diff --git a/python/helpers/setuptools-36.8.0.tar.gz b/python/helpers/setuptools-36.8.0.tar.gz deleted file mode 100644 index 4d67276d7e0c..000000000000 Binary files a/python/helpers/setuptools-36.8.0.tar.gz and /dev/null differ diff --git a/python/helpers/virtualenv-15.2.0.tar.gz b/python/helpers/virtualenv-15.2.0.tar.gz deleted file mode 100644 index 4e7474992c5c..000000000000 Binary files a/python/helpers/virtualenv-15.2.0.tar.gz and /dev/null differ diff --git a/python/psi-api/src/com/jetbrains/python/psi/LanguageLevel.java b/python/psi-api/src/com/jetbrains/python/psi/LanguageLevel.java index baf1bac837e6..eaa6e7cc7088 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/LanguageLevel.java +++ b/python/psi-api/src/com/jetbrains/python/psi/LanguageLevel.java @@ -41,6 +41,9 @@ public enum LanguageLevel { */ @Deprecated PYTHON25(25, false, true, false, false), + /** + * @apiNote This level is not supported since 2019.1. + */ PYTHON26(26, true, true, false, false), PYTHON27(27, true, true, true, false), /** @@ -67,16 +70,23 @@ public enum LanguageLevel { */ @Deprecated PYTHON33(33, true, false, true, true), + /** + * @apiNote This level is not supported since 2019.1. + */ PYTHON34(34, true, false, true, true), PYTHON35(35, true, false, true, true), PYTHON36(36, true, false, true, true), PYTHON37(37, true, false, true, true); + /** + * 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. + */ public static final List SUPPORTED_LEVELS = ImmutableList.copyOf( Stream .of(values()) - .filter(v -> v.myVersion > 33 || v.myVersion == 26 || v.myVersion == 27) + .filter(v -> v.myVersion > 34 || v.myVersion == 27) .collect(Collectors.toList()) ); diff --git a/python/src/com/jetbrains/python/codeInsight/functionTypeComments/psi/PyFunctionTypeAnnotationFile.java b/python/src/com/jetbrains/python/codeInsight/functionTypeComments/psi/PyFunctionTypeAnnotationFile.java index 6ca96531cffc..1d2c0ecd3051 100644 --- a/python/src/com/jetbrains/python/codeInsight/functionTypeComments/psi/PyFunctionTypeAnnotationFile.java +++ b/python/src/com/jetbrains/python/codeInsight/functionTypeComments/psi/PyFunctionTypeAnnotationFile.java @@ -61,7 +61,7 @@ public class PyFunctionTypeAnnotationFile extends PyFileImpl implements PyExpres @Override public LanguageLevel getLanguageLevel() { // The same as for .pyi files - return LanguageLevel.PYTHON35; + return LanguageLevel.getLatest(); } @Override diff --git a/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java b/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java index 09990e1b7539..324e511fccc4 100644 --- a/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyCompatibilityInspection.java @@ -43,14 +43,15 @@ import com.jetbrains.python.psi.types.PyTypeChecker; import com.jetbrains.python.psi.types.TypeEvalContext; import com.jetbrains.python.validation.CompatibilityVisitor; import com.jetbrains.python.validation.UnsupportedFeaturesUtil; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.util.*; import java.util.List; +import java.util.*; /** * User: catherine @@ -71,14 +72,20 @@ public class PyCompatibilityInspection extends PyInspection { public static final List DEFAULT_PYTHON_VERSIONS = ImmutableList.of(LanguageLevel.PYTHON27, LanguageLevel.getLatest()); @NotNull - public static final List SUPPORTED_LEVELS = ContainerUtil.map(LanguageLevel.SUPPORTED_LEVELS, LanguageLevel::toString); + public static final List SUPPORTED_LEVELS = StreamEx + .of(LanguageLevel.values()) + .filter(v -> v.isPython2() && v.isAtLeast(LanguageLevel.PYTHON26) || v.isAtLeast(LanguageLevel.PYTHON34)) + .toImmutableList(); + + @NotNull + private static final List SUPPORTED_IN_SETTINGS = ContainerUtil.map(SUPPORTED_LEVELS, LanguageLevel::toString); // Legacy DefaultJDOMExternalizer requires public fields for proper serialization public JDOMExternalizableStringList ourVersions = new JDOMExternalizableStringList(); public PyCompatibilityInspection () { if (ApplicationManager.getApplication().isUnitTestMode()) { - ourVersions.addAll(SUPPORTED_LEVELS); + ourVersions.addAll(SUPPORTED_IN_SETTINGS); } else { ourVersions.addAll(ContainerUtil.map(DEFAULT_PYTHON_VERSIONS, LanguageLevel::toString)); @@ -101,7 +108,7 @@ public class PyCompatibilityInspection extends PyInspection { List result = new ArrayList<>(); for (String version : ourVersions) { - if (SUPPORTED_LEVELS.contains(version)) { + if (SUPPORTED_IN_SETTINGS.contains(version)) { LanguageLevel level = LanguageLevel.fromPythonVersion(version); result.add(level); } @@ -119,8 +126,8 @@ public class PyCompatibilityInspection extends PyInspection { @Override public JComponent createOptionsPanel() { final ElementsChooser chooser = new ElementsChooser<>(true); - chooser.setElements(SUPPORTED_LEVELS, false); - chooser.markElements(ContainerUtil.filter(ourVersions, SUPPORTED_LEVELS::contains)); + chooser.setElements(SUPPORTED_IN_SETTINGS, false); + chooser.markElements(ContainerUtil.filter(ourVersions, SUPPORTED_IN_SETTINGS::contains)); chooser.addElementsMarkListener(new ElementsChooser.ElementsMarkListener() { @Override public void elementMarkChanged(String element, boolean isMarked) { diff --git a/python/src/com/jetbrains/python/inspections/PyCompatibilityInspectionAdvertiser.java b/python/src/com/jetbrains/python/inspections/PyCompatibilityInspectionAdvertiser.java index bb01582b1213..9b7fafadd188 100644 --- a/python/src/com/jetbrains/python/inspections/PyCompatibilityInspectionAdvertiser.java +++ b/python/src/com/jetbrains/python/inspections/PyCompatibilityInspectionAdvertiser.java @@ -146,7 +146,7 @@ public class PyCompatibilityInspectionAdvertiser implements Annotator { private static List getVersionsNewerThan(@NotNull LanguageLevel version) { final List result = new ArrayList<>(); final LanguageLevel latest = LanguageLevel.getLatest(); - for (LanguageLevel level : LanguageLevel.SUPPORTED_LEVELS) { + for (LanguageLevel level : PyCompatibilityInspection.SUPPORTED_LEVELS) { if (version.isOlderThan(level) && latest.isAtLeast(level)) { result.add(level); } diff --git a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java index d48eb2115db5..b062437ba660 100644 --- a/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java +++ b/python/src/com/jetbrains/python/packaging/PyPackageManagerImpl.java @@ -49,11 +49,8 @@ import java.util.regex.Pattern; public class PyPackageManagerImpl extends PyPackageManager { private static final String SETUPTOOLS_VERSION = "39.1.0"; - private static final String SETUPTOOLS_VERSION_26 = "36.8.0"; private static final String PIP_VERSION = "10.0.1"; - private static final String PIP_VERSION_26 = "9.0.3"; private static final String VIRTUALENV_VERSION = "16.0.0"; - private static final String VIRTUALENV_VERSION_26 = "15.2.0"; private static final int ERROR_NO_SETUPTOOLS = 3; @@ -91,17 +88,16 @@ public class PyPackageManagerImpl extends PyPackageManager { @Override public void installManagement() throws ExecutionException { final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(getSdk()); - if (languageLevel.isOlderThan(LanguageLevel.PYTHON26)) { + if (languageLevel.isOlderThan(LanguageLevel.PYTHON27)) { throw new ExecutionException("Package management for Python " + languageLevel + " is not supported. " + - "Upgrade your project interpreter to Python " + LanguageLevel.PYTHON26 + " or newer"); + "Upgrade your project interpreter to Python " + LanguageLevel.PYTHON27 + " or newer"); } - final boolean py26 = languageLevel == LanguageLevel.PYTHON26; if (!refreshAndCheckForSetuptools()) { - installManagement(PyPackageUtil.SETUPTOOLS + "-" + (py26 ? SETUPTOOLS_VERSION_26 : SETUPTOOLS_VERSION)); + installManagement(PyPackageUtil.SETUPTOOLS + "-" + SETUPTOOLS_VERSION); } if (PyPackageUtil.findPackage(refreshAndGetPackages(false), PyPackageUtil.PIP) == null) { - installManagement(PyPackageUtil.PIP + "-" + (py26 ? PIP_VERSION_26 : PIP_VERSION)); + installManagement(PyPackageUtil.PIP + "-" + PIP_VERSION); } } @@ -316,9 +312,9 @@ public class PyPackageManagerImpl extends PyPackageManager { final Sdk sdk = getSdk(); final LanguageLevel languageLevel = getOrRequestLanguageLevelForSdk(sdk); - if (languageLevel.isOlderThan(LanguageLevel.PYTHON26)) { + if (languageLevel.isOlderThan(LanguageLevel.PYTHON27)) { throw new ExecutionException("Creating virtual environment for Python " + languageLevel + " is not supported. " + - "Upgrade your project interpreter to Python " + LanguageLevel.PYTHON26 + " or newer"); + "Upgrade your project interpreter to Python " + LanguageLevel.PYTHON27 + " or newer"); } final boolean usePyVenv = languageLevel.isAtLeast(LanguageLevel.PYTHON33); @@ -335,8 +331,7 @@ public class PyPackageManagerImpl extends PyPackageManager { args.add("--system-site-packages"); } args.add(destinationDir); - final boolean py26 = languageLevel == LanguageLevel.PYTHON26; - final String name = "virtualenv-" + (py26 ? VIRTUALENV_VERSION_26 : VIRTUALENV_VERSION); + final String name = "virtualenv-" + VIRTUALENV_VERSION; final String dirName = extractHelper(name + ".tar.gz"); try { final String fileName = dirName + name + mySeparator + "virtualenv.py"; diff --git a/python/src/com/jetbrains/python/pyi/PyiFile.kt b/python/src/com/jetbrains/python/pyi/PyiFile.kt index fb19fa3de7a3..f82500415fee 100644 --- a/python/src/com/jetbrains/python/pyi/PyiFile.kt +++ b/python/src/com/jetbrains/python/pyi/PyiFile.kt @@ -32,7 +32,7 @@ class PyiFile(viewProvider: FileViewProvider) : PyFileImpl(viewProvider, PyiLang override fun toString(): String = "PyiFile:$name" - override fun getLanguageLevel(): LanguageLevel = LanguageLevel.PYTHON37 + override fun getLanguageLevel(): LanguageLevel = LanguageLevel.getLatest() override fun multiResolveName(name: String, exported: Boolean): List { if (name == "function" && PyBuiltinCache.getInstance(this).builtinsFile == this) return emptyList() diff --git a/python/src/com/jetbrains/python/sdk/add/PyAddNewCondaEnvPanel.kt b/python/src/com/jetbrains/python/sdk/add/PyAddNewCondaEnvPanel.kt index 7a8ebdd0df47..cc34ad689215 100644 --- a/python/src/com/jetbrains/python/sdk/add/PyAddNewCondaEnvPanel.kt +++ b/python/src/com/jetbrains/python/sdk/add/PyAddNewCondaEnvPanel.kt @@ -74,9 +74,7 @@ class PyAddNewCondaEnvPanel(private val project: Project?, layout = BorderLayout() // https://conda.io/docs/user-guide/install/index.html#system-requirements - val supportedLanguageLevels = - listOf(LanguageLevel.PYTHON36, LanguageLevel.PYTHON35, LanguageLevel.PYTHON34, LanguageLevel.PYTHON27) - .map { it.toString() } + val supportedLanguageLevels = listOf(LanguageLevel.PYTHON36, LanguageLevel.PYTHON35, LanguageLevel.PYTHON27).map { it.toString() } languageLevelsField = JComboBox(supportedLanguageLevels.toTypedArray()).apply { selectedItem = if (itemCount > 0) getItemAt(0) else null