Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/claude-code-marketplace.json",
"name": "heph-marketplace",
"version": "0.1.12",
"version": "0.1.13",
"description": "Claude Code plugins for the heph build system, co-located with the docs.",
"owner": {
"name": "hephbuild",
Expand Down
2 changes: 1 addition & 1 deletion plugins/heph-expert/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/claude-code-plugin.json",
"name": "heph-expert",
"version": "0.1.12",
"version": "0.1.13",
"description": "Expert assistance for the heph build system: author BUILD files, debug caching and sandbox issues, wire up CI, and explain the target graph.",
"author": {
"name": "hephbuild"
Expand Down
8 changes: 7 additions & 1 deletion plugins/heph-expert/skills/heph/references/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ parameters that forward to `target()`. `heph.types.<driver>.Kwargs` (e.g.
`heph.types.bash.Kwargs`, `heph.types.oci.image.Kwargs`; registered drivers
only) types a wrapper's `**kwargs` per key: `target()`'s fields minus `driver`
plus the driver's fields, closed (unknown key = type error), every key optional
and `None`-accepting; checked by lint and at evaluation. A file is checked only by the package whose directory
and `None`-accepting; checked by lint and at evaluation. Starlark's `typing`
namespace is a global in every BUILD file (`typing.Callable`, `typing.Any`,
`typing.Iterable`, `typing.Never`): `fn: typing.Callable[[str], bool]` types a
function parameter — lint checks the passed function's signature, evaluation
only that it is a function; bare `typing.Callable` / `typing.Any` satisfy
`requireTypeAnnotations` and are not checked further. `heph.types.Callable` /
`heph.types.Any` fail pointing at `typing.<name>`. A file is checked only by the package whose directory
holds it — name shared helpers `*.BUILD`. A user target with a check's name
shadows it; `heph validate` fails on that. Full page:
<https://hephbuild.github.io/docs/guides/checking-build-files>.
Expand Down
30 changes: 29 additions & 1 deletion website/docs/guides/checking-build-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ def lib(deps: heph.types.Deps = []): ... # accepts one address or a map
Only `build-lint-check` checks inferred types. Evaluation checks annotations
alone, so it accepts any argument for a parameter typed only by its default.

### Functions and `Any`

Every BUILD file has the `typing` namespace: `typing.Callable`, `typing.Any`,
`typing.Iterable` and `typing.Never`. A parameter that takes a function names
the function's parameter types and return type:

```python title="defs.BUILD"
def apply(fn: typing.Callable[[str], str], x: str) -> str:
return fn(x)

def keep(xs: list[str], filter: list[str] | typing.Callable[[str], bool]) -> list[str]:
...
```

`build-lint-check` checks a function passed there against that signature:
`apply(_len, "s")`, with `def _len(s: str) -> int`, reports:

```text
type-error: Expected type `typing.Callable[[str], str]` but got `def(s: str) -> int`
```

Evaluation checks only that the argument is a function. Bare `typing.Callable`
takes any function and `typing.Any` takes any value; both satisfy
[`requireTypeAnnotations`](#requiring-type-annotations), and neither is
checked any further.

### Allowing `None`

A parameter takes `None` only when its annotation says `| None`, or when it is
Expand Down Expand Up @@ -130,7 +156,9 @@ def lib(name: str, deps: heph.types.Deps = None, labels: heph.types.Labels = Non
A field alias widens with its field and never narrows. `transitive` and
`approval` have no alias; a driver's own fields are typed by its
[`Kwargs`](#driver-kwargs). An unknown name such as `heph.types.Nope` fails
before evaluation and lists the known aliases and driver namespaces. In the
before evaluation and lists the known aliases and driver namespaces.
`heph.types.Callable`, `heph.types.Any` and the other `typing` names fail
pointing at `typing.<name>` (see [Functions and `Any`](#functions-and-any)). In the
editor, `heph.types.` completes the aliases, then the driver namespaces, and
each alias shows its expansion on hover.

Expand Down
1 change: 1 addition & 0 deletions website/docs/plugins/buildfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ The plugin exposes a fixed set of builtins:
| `provider_state(provider, **kwargs)` | — | Hand package-level state to a provider. |
| `heph.core` | namespace | Host platform info and current package. See [below](#hephcore--host-platform). |
| `heph.types` | namespace | Type aliases for `target()` fields, to annotate wrapper `def`s. See [`heph.types`](/docs/guides/checking-build-files#hephtypes). |
| `typing` | namespace | `typing.Callable`, `typing.Any`, `typing.Iterable`, `typing.Never`, to annotate `def` parameters. See [Functions and `Any`](/docs/guides/checking-build-files#functions-and-any). |

`file()` and `glob()` resolve to [filesystem](./fs.md) addresses; `query()`
resolves to a [query](./query.md) address. All three drop straight into a
Expand Down
Loading