Skip to content

Commit 5c6a8ed

Browse files
Merge branch 'simplify-deps' into HEAD
2 parents 8ecc4fa + 60739e5 commit 5c6a8ed

File tree

19 files changed

+156
-297
lines changed

19 files changed

+156
-297
lines changed

examples/demo/MODULE.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,3 @@ pip.parse(
3737
},
3838
)
3939
use_repo(pip, "pip")
40-
41-
types = use_extension("@rules_mypy//mypy:types.bzl", "types")
42-
types.requirements(
43-
name = "pip_types",
44-
pip_requirements = "@pip//:requirements.bzl",
45-
requirements_txt = "//:requirements.txt",
46-
)
47-
use_repo(types, "pip_types")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
load("@rules_python//python:py_library.bzl", "py_library")
2+
3+
py_library(
4+
name = "lib",
5+
srcs = glob(["lib/**/*.py"]),
6+
deps = [":foo"],
7+
)
8+
9+
py_library(
10+
name = "foo",
11+
imports = ["."],
12+
pyi_srcs = glob(["foo/**/*.pyi"]),
13+
)
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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"Custom py_library rule that also runs mypy."
22

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

6-
mypy_aspect = mypy(types = types)
6+
stubs = load_stubs(requirements = all_requirements)
7+
8+
mypy_aspect = mypy(stubs = stubs)

examples/opt-in/MODULE.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,3 @@ pip.parse(
3737
},
3838
)
3939
use_repo(pip, "pip")
40-
41-
types = use_extension("@rules_mypy//mypy:types.bzl", "types")
42-
types.requirements(
43-
name = "pip_types",
44-
pip_requirements = "@pip//:requirements.bzl",
45-
requirements_txt = "//:requirements.txt",
46-
)
47-
use_repo(types, "pip_types")

examples/opt-in/py.bzl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"Custom py_library rule that also runs mypy."
22

3-
load("@pip_types//:types.bzl", "types")
4-
load("@rules_mypy//mypy:mypy.bzl", "mypy")
3+
load("@pip//:requirements.bzl", "all_requirements")
4+
load("@rules_mypy//mypy:mypy.bzl", "load_stubs", "mypy")
5+
6+
stubs = load_stubs(requirements = all_requirements)
57

68
mypy_aspect = mypy(
79
# only run mypy on targets with the typecheck tag
810
opt_in_tags = ["typecheck"],
9-
types = types,
11+
stubs = stubs,
1012
)

mypy/BUILD.bazel

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,3 @@ bzl_library(
55
srcs = ["mypy.bzl"],
66
visibility = ["//visibility:public"],
77
)
8-
9-
bzl_library(
10-
name = "py_type_library",
11-
srcs = ["py_type_library.bzl"],
12-
visibility = ["//visibility:public"],
13-
)
14-
15-
bzl_library(
16-
name = "types",
17-
srcs = ["types.bzl"],
18-
visibility = ["//visibility:public"],
19-
)

mypy/mypy.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
"Public API for interacting with the mypy rule."
22

3-
load("//mypy/private:mypy.bzl", _mypy = "mypy", _mypy_cli = "mypy_cli")
3+
load(
4+
"//mypy/private:mypy.bzl",
5+
_load_stubs = "load_stubs",
6+
_mypy = "mypy",
7+
_mypy_cli = "mypy_cli",
8+
)
9+
10+
load_stubs = _load_stubs
411

512
# re-export mypy aspect factory
613
mypy = _mypy

mypy/private/BUILD.bazel

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2-
load("@rules_mypy_pip//:requirements.bzl", "requirement")
3-
load("@rules_python//python:py_binary.bzl", "py_binary")
42
load("@rules_uv//uv:pip.bzl", "pip_compile")
53
load("@rules_uv//uv:venv.bzl", "create_venv")
64
load(":mypy.bzl", "mypy_cli")
@@ -16,18 +14,6 @@ bzl_library(
1614
visibility = ["//mypy:__subpackages__"],
1715
)
1816

19-
bzl_library(
20-
name = "py_type_library_rules",
21-
srcs = ["py_type_library.bzl"],
22-
visibility = ["//mypy:__subpackages__"],
23-
)
24-
25-
bzl_library(
26-
name = "types_rules",
27-
srcs = ["types.bzl"],
28-
visibility = ["//mypy:__subpackages__"],
29-
)
30-
3117
pip_compile(
3218
name = "generate_requirements_lock",
3319
requirements_in = "requirements.in",
@@ -40,14 +26,3 @@ create_venv(
4026
)
4127

4228
mypy_cli(name = "mypy")
43-
44-
py_binary(
45-
name = "py_type_library",
46-
srcs = ["py_type_library.py"],
47-
main = "py_type_library.py",
48-
python_version = "3.12",
49-
visibility = ["//visibility:public"],
50-
deps = [
51-
requirement("click"),
52-
],
53-
)

0 commit comments

Comments
 (0)