From e90b6b09b1da65e1fe4f0f501d440bcfca9e4708 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Tue, 21 Mar 2023 20:15:58 +0200 Subject: [PATCH] PY-53599 Declare only submodules available in qualified "tensorflow.xxx" imports Modules re-exported as attributes are already covered by explicit declarations for type checkers under "if _typing.TYPE_CHECKING:" in tensorflow/__init__.py (see https://github.com/tensorflow/tensorflow/pull/54104). Only detached submodules made available in imports through a module's __path__ manipulations should be special-cased on our side. GitOrigin-RevId: 5d5b732a18d06936dd6047150dfee3028f3fc0d4 --- .../src/com/jetbrains/tensorFlow/PyTensorFlow.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/python/python-psi-impl/src/com/jetbrains/tensorFlow/PyTensorFlow.kt b/python/python-psi-impl/src/com/jetbrains/tensorFlow/PyTensorFlow.kt index 2449434fc272..e581c28456d2 100644 --- a/python/python-psi-impl/src/com/jetbrains/tensorFlow/PyTensorFlow.kt +++ b/python/python-psi-impl/src/com/jetbrains/tensorFlow/PyTensorFlow.kt @@ -15,17 +15,15 @@ import com.jetbrains.python.psi.resolve.PyQualifiedNameResolveContext import com.jetbrains.python.psi.resolve.resolveQualifiedName private val LAYOUT_PER_VERSION: List>> = listOf( - VersionRange("2.6.0", null) to mapOf( + VersionRange("2.6.0rc0", null) to mapOf( "keras" to "keras.api._v2.keras", + // losses, metrics, optimizers, initializers are not available as tensorflow submodules, only as its attributes + // i.e. "from tensorflow import losses" is possible, but not "import tensorflow.losses". "estimator" to "tensorflow_estimator.python.estimator.api._v2.estimator", - "initializers" to "keras.api._v2.keras.initializers", - "losses" to "keras.api._v2.keras.losses", - "metrics" to "keras.api._v2.keras.metrics", - "optimizers" to "keras.api._v2.keras.optimizers", "summary" to "tensorboard.summary._tf.summary", "*" to "tensorflow._api.v2", ), - VersionRange("2.0.0a0", "2.6.0") to mapOf( + VersionRange("2.0.0a0", "2.6.0rc0") to mapOf( "compiler" to "tensorflow_core.compiler", "core" to "tensorflow_core.core", "tools" to "tensorflow_core.tools",