Skip to content

Commit ad1280a

Browse files
Add repro for stubs added implicitly
1 parent 5c6a8ed commit ad1280a

File tree

9 files changed

+41
-5
lines changed

9 files changed

+41
-5
lines changed

examples/demo/manual_stubs/BUILD.bazel renamed to examples/demo/manual_stubs/explicit/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ load("@rules_python//python:py_library.bzl", "py_library")
33
py_library(
44
name = "lib",
55
srcs = glob(["lib/**/*.py"]),
6-
deps = [":foo"],
6+
deps = [":foo-stubs"],
77
)
88

99
py_library(
10-
name = "foo",
10+
name = "foo-stubs",
1111
imports = ["."],
1212
pyi_srcs = glob(["foo/**/*.pyi"]),
1313
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load("@pip//:requirements.bzl", "requirement")
2+
load("@rules_python//python:py_library.bzl", "py_library")
3+
4+
py_library(
5+
name = "lib",
6+
srcs = glob(["lib/**/*.py"]),
7+
deps = [
8+
# actual dependency here doesn't matter, we just need some dependency
9+
# to implicitly provide stubs for; see `py.bzl` for the hook-up
10+
requirement("six"),
11+
],
12+
)
13+
14+
py_library(
15+
name = "foo-stubs",
16+
imports = ["."],
17+
pyi_srcs = glob(["foo/**/*.pyi"]),
18+
visibility = ["//visibility:public"],
19+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Foo:
2+
pass
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from foo import Foo

examples/demo/py.bzl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
"Custom py_library rule that also runs mypy."
22

3-
load("@pip//:requirements.bzl", "all_requirements")
3+
load("@pip//:requirements.bzl", "all_requirements", "requirement")
44
load("@rules_mypy//mypy:mypy.bzl", "load_stubs", "mypy")
55

6-
stubs = load_stubs(requirements = all_requirements)
6+
stubs = load_stubs(
7+
requirements = all_requirements,
8+
overrides = {
9+
# See manual_stubs/implicit/
10+
requirement("six"): "@@//manual_stubs/implicit:foo-stubs",
11+
},
12+
)
713

814
mypy_aspect = mypy(stubs = stubs)

examples/demo/requirements.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
cachetools~=5.4.0
1+
# ----- thm/ dependencies ----- #
22
numpy~=1.26.4
3+
cachetools~=5.4.0
34
types-cachetools~=5.4.0.20240717
5+
6+
# ---- manual_stubs/ dependencies ----- #
7+
six==1.17.0

examples/demo/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ numpy==1.26.4 \
4444
--hash=sha256:f870204a840a60da0b12273ef34f7051e98c3b5961b61b0c2c1be6dfd64fbcd3 \
4545
--hash=sha256:ffa75af20b44f8dba823498024771d5ac50620e6915abac414251bd971b4529f
4646
# via -r requirements.in
47+
six==1.17.0 \
48+
--hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274 \
49+
--hash=sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81
50+
# via -r requirements.in
4751
types-cachetools==5.4.0.20240717 \
4852
--hash=sha256:1eae90c48760bac44ab89108be938e8ce1d740910f2d4b68446dcdc82763f186 \
4953
--hash=sha256:67c84c26df988039be68344b162afd2dd7cd3741dc08e7d67aa1954782fd2d2a

0 commit comments

Comments
 (0)