Skip to content

Commit 9f3f1c8

Browse files
committed
Include boto3-stubs in gazelle_python.yaml on type_checking_imports test
1 parent 8208696 commit 9f3f1c8

File tree

8 files changed

+33
-1
lines changed

8 files changed

+33
-1
lines changed

gazelle/python/testdata/type_checking_imports/BUILD.out

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ py_library(
1414
py_library(
1515
name = "baz",
1616
srcs = ["baz.py"],
17+
pyi_deps = [
18+
"@gazelle_python_test//boto3",
19+
"@gazelle_python_test//boto3_stubs",
20+
],
1721
visibility = ["//:__subpackages__"],
1822
)
1923

2024
py_library(
2125
name = "foo",
2226
srcs = ["foo.py"],
23-
pyi_deps = ["@gazelle_python_test//djangorestframework"],
27+
pyi_deps = [
28+
"@gazelle_python_test//boto3_stubs",
29+
"@gazelle_python_test//djangorestframework",
30+
],
2431
visibility = ["//:__subpackages__"],
2532
deps = ["@gazelle_python_test//boto3"],
2633
)

gazelle/python/testdata/type_checking_imports/baz.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
16+
# While this format is not official, it is supported by most type checkers and
17+
# is used in the wild to avoid importing the typing module.
18+
TYPE_CHECKING = False
19+
if TYPE_CHECKING:
20+
# Both boto3 and boto3_stubs should be added to pyi_deps.
21+
import boto3
22+
1523
X = 1

gazelle/python/testdata/type_checking_imports/foo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import typing
1616

17+
# boto3 should be added to deps. boto3_stubs and djangorestframework should be added to pyi_deps.
1718
import boto3
1819

1920
if typing.TYPE_CHECKING:

gazelle/python/testdata/type_checking_imports/gazelle_python.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
manifest:
1616
modules_mapping:
1717
boto3: boto3
18+
boto3_stubs: boto3_stubs
1819
rest_framework: djangorestframework
1920
pip_deps_repository_name: gazelle_python_test

gazelle/python/testdata/type_checking_imports_disabled/BUILD.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ py_library(
1717
name = "baz",
1818
srcs = ["baz.py"],
1919
visibility = ["//:__subpackages__"],
20+
deps = [
21+
"@gazelle_python_test//boto3",
22+
"@gazelle_python_test//boto3_stubs",
23+
],
2024
)
2125

2226
py_library(
@@ -25,6 +29,7 @@ py_library(
2529
visibility = ["//:__subpackages__"],
2630
deps = [
2731
"@gazelle_python_test//boto3",
32+
"@gazelle_python_test//boto3_stubs",
2833
"@gazelle_python_test//djangorestframework",
2934
],
3035
)

gazelle/python/testdata/type_checking_imports_disabled/baz.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
16+
# While this format is not official, it is supported by most type checkers and
17+
# is used in the wild to avoid importing the typing module.
18+
TYPE_CHECKING = False
19+
if TYPE_CHECKING:
20+
# Both boto3 and boto3_stubs should be added to pyi_deps.
21+
import boto3
22+
1523
X = 1

gazelle/python/testdata/type_checking_imports_disabled/foo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import typing
1616

17+
# boto3 should be added to deps. boto3_stubs and djangorestframework should be added to pyi_deps.
1718
import boto3
1819

1920
if typing.TYPE_CHECKING:

gazelle/python/testdata/type_checking_imports_disabled/gazelle_python.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
manifest:
1616
modules_mapping:
1717
boto3: boto3
18+
boto3_stubs: boto3_stubs
1819
rest_framework: djangorestframework
1920
pip_deps_repository_name: gazelle_python_test

0 commit comments

Comments
 (0)