Skip to content

Commit

Permalink
feat(runfiles): Added type hints to @rules_python//python/runfiles (#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
UebelAndre and aignas authored Dec 27, 2023
1 parent 02591a5 commit 4c2d7d9
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 173 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: mypy

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

defaults:
run:
shell: bash

jobs:
ci:
runs-on: ubuntu-20.04
steps:
# Checkout the code
- uses: actions/checkout@v2
- uses: jpetrucciani/mypy-check@master
with:
requirements: 1.6.0
python_version: 3.8
path: 'python/runfiles'
- uses: jpetrucciani/mypy-check@master
with:
requirements: 1.6.0
python_version: 3.8
path: 'tests/runfiles'

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ A brief description of the categories of changes:

### Changed

* (runfiles) `rules_python.python.runfiles` now directly implements type hints
and drops support for python2 as a result.

* (toolchains) `py_runtime`, `py_runtime_pair`, and `PyRuntimeInfo` now use the
rules_python Starlark implementation, not the one built into Bazel. NOTE: This
only applies to Bazel 6+; Bazel 5 still uses the builtin implementation.
Expand Down
2 changes: 2 additions & 0 deletions python/runfiles/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ py_library(
"__init__.py",
"runfiles.py",
],
data = ["py.typed"],
imports = [
# Add the repo root so `import python.runfiles.runfiles` works. This makes it agnostic
# to the --experimental_python_import_all_repositories setting.
Expand All @@ -49,6 +50,7 @@ py_wheel(
dist_folder = "dist",
distribution = "bazel_runfiles",
homepage = "https://github.com/bazelbuild/rules_python",
python_requires = ">=3.7",
strip_path_prefixes = ["python"],
twine = "@publish_deps_twine//:pkg",
# this can be replaced by building with --stamp --embed_label=1.2.3
Expand Down
Empty file added python/runfiles/py.typed
Empty file.
Loading

0 comments on commit 4c2d7d9

Please sign in to comment.