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
This commit is contained in:
Mikhail Golubev
2023-07-20 19:36:10 +00:00
committed by intellij-monorepo-bot
parent 2e809ff582
commit e90b6b09b1
@@ -15,17 +15,15 @@ import com.jetbrains.python.psi.resolve.PyQualifiedNameResolveContext
import com.jetbrains.python.psi.resolve.resolveQualifiedName
private val LAYOUT_PER_VERSION: List<Pair<VersionRange, Map<String, String>>> = 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",