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
4 changes: 3 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ $ pnpm run type-check

This runs `astro check` for the site and Oxlint's type-check mode for the
plain TypeScript packages, plus `uv run --locked ty check` for Python
tooling. Ty treats warnings as failures. The theme also exposes
tooling. Ty checks the site scripts, API exporter, and exporter tests.
CI checks types and runs the Python tests on 3.12 and 3.14. Ty treats
warnings as failures. The theme also exposes
`type-check:tsc` for a direct compiler check; it is separate from the root gate.

Use the inner loop for cross-port mappings, native navigation, and native
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ concurrency:
cancel-in-progress: true

jobs:
python:
name: Python tooling (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12', '3.14']
env:
UV_PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v10.4.0
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Check Python types
run: uv run --locked ty check --python-version ${{ matrix.python-version }}
- name: Test Python tooling
run: uv run --locked python -m pytest packages/api-model/test

fsharp-records:
name: F# record extraction (.NET ${{ matrix.sdk }})
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ publication. Keep those worktrees alongside their normal checkouts, using
Scope `aws s3 sync --delete` to one job's own prefix, never a bucket root or
an entire language root.

## Python typing

Give callers the most precise signature that covers supported behavior. Use
`object` for a parameter only when every value is valid or when the function
accepts unknown input for validation. Narrow unknown values before using them.
Reserve `Any` for an inherently dynamic interface where Python cannot express
the input contract. Explain the reason there and keep unchecked values out of
the rest of the API.

Before weakening a type, inspect real callers and try a precise alternative.
A union can describe known alternatives, a protocol can name the operations a
caller must provide, and a type parameter can preserve the relationship between
an input and its result. Try both a supported call and a plausible misuse with
ty. Check what downstream callers infer, whether the error is understandable,
and whether existing valid calls still work. Never widen a type, cast a value,
or suppress a diagnostic solely to make the checker pass.

## References

- [README.md](README.md)
Expand Down
11 changes: 6 additions & 5 deletions packages/api-model/test/test_haskell_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

ROOT = Path(__file__).resolve().parents[1]
SPEC = importlib.util.spec_from_file_location("haskell_export", ROOT / "scripts/export-haskell.py")
assert SPEC is not None and SPEC.loader is not None, "Cannot load the Haskell API exporter"
EXPORT = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(EXPORT)
FIXTURE = ROOT / "test/fixtures/haskell-native"
Expand Down Expand Up @@ -244,11 +245,11 @@ def test_explicit_missing_source_anchors_fail_instead_of_becoming_file_links(sel
with self.subTest(line=line):
inputs = _profile_inputs()
html = inputs[0]["LibTmux.Snapshot"]
anchor = (
re.search(r"src/LibTmux.Internal.Graph.html#line-\d+", html)[0]
if line
else "src/LibTmux.Internal.Graph.html#Session"
)
anchor = "src/LibTmux.Internal.Graph.html#Session"
if line:
match = re.search(r"src/LibTmux.Internal.Graph.html#line-\d+", html)
assert match is not None, "Fixture is missing its native source line link"
anchor = match[0]
replacement = "src/LibTmux.Internal.Graph.html#" + (
"line-999999" if line else "Absent"
)
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ docs = [
]
lint = [
"ruff>=0.16.1",
"ty>=0.0.35",
"ty==0.0.113",
]
testing = [
"libtmux==0.68.0",
Expand All @@ -29,6 +29,9 @@ testing = [
package = false
exclude-newer = "3 days"

[tool.uv.exclude-newer-package]
ty = false

[tool.ruff]
target-version = "py312"
line-length = 100
Expand Down Expand Up @@ -61,7 +64,7 @@ convention = "numpy"
python-version = "3.12"

[tool.ty.src]
include = ["scripts", "packages/api-model/scripts"]
include = ["scripts", "packages/api-model/scripts", "packages/api-model/test"]

[tool.ty.terminal]
error-on-warning = true
49 changes: 26 additions & 23 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading