Skip to content

Commit 4c2d7d9

Browse files
UebelAndreaignas
andauthored
feat(runfiles): Added type hints to @rules_python//python/runfiles (#1654)
This change adds mypy types directly to the `rules_python.python.runfiles` library as well as regression testing to CI. --------- Co-authored-by: Ignas Anikevicius <[email protected]>
1 parent 02591a5 commit 4c2d7d9

File tree

6 files changed

+210
-173
lines changed

6 files changed

+210
-173
lines changed

.github/workflows/mypy.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: mypy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
ci:
18+
runs-on: ubuntu-20.04
19+
steps:
20+
# Checkout the code
21+
- uses: actions/checkout@v2
22+
- uses: jpetrucciani/mypy-check@master
23+
with:
24+
requirements: 1.6.0
25+
python_version: 3.8
26+
path: 'python/runfiles'
27+
- uses: jpetrucciani/mypy-check@master
28+
with:
29+
requirements: 1.6.0
30+
python_version: 3.8
31+
path: 'tests/runfiles'
32+

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ A brief description of the categories of changes:
2121

2222
### Changed
2323

24+
* (runfiles) `rules_python.python.runfiles` now directly implements type hints
25+
and drops support for python2 as a result.
26+
2427
* (toolchains) `py_runtime`, `py_runtime_pair`, and `PyRuntimeInfo` now use the
2528
rules_python Starlark implementation, not the one built into Bazel. NOTE: This
2629
only applies to Bazel 6+; Bazel 5 still uses the builtin implementation.

python/runfiles/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ py_library(
2727
"__init__.py",
2828
"runfiles.py",
2929
],
30+
data = ["py.typed"],
3031
imports = [
3132
# Add the repo root so `import python.runfiles.runfiles` works. This makes it agnostic
3233
# to the --experimental_python_import_all_repositories setting.
@@ -49,6 +50,7 @@ py_wheel(
4950
dist_folder = "dist",
5051
distribution = "bazel_runfiles",
5152
homepage = "https://github.com/bazelbuild/rules_python",
53+
python_requires = ">=3.7",
5254
strip_path_prefixes = ["python"],
5355
twine = "@publish_deps_twine//:pkg",
5456
# this can be replaced by building with --stamp --embed_label=1.2.3

python/runfiles/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)