From 9c9e9055fe1369b33e0c798df5509ed0bed33ea8 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 29 Nov 2026 11:44:26 -0600 Subject: [PATCH 1/3] tooling(ci) Check documentation scripts and exporter tests with ty why: The previous source list left the exporter tests outside the type gate. Those tests run the Python exporter used to assemble the site. what: - Pin ty 0.0.113 with its own package cooldown exception. - Check the maintained Python tests alongside scripts and exporter code. - Run the type and test commands on Python 3.12 and 3.14 in CI. --- .github/CONTRIBUTING.md | 4 +++- .github/workflows/test.yml | 22 +++++++++++++++++ pyproject.toml | 7 ++++-- uv.lock | 49 ++++++++++++++++++++------------------ 4 files changed, 56 insertions(+), 26 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 60a0457ee..58be40bb0 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec15c166a..4616208e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index d524a1d68..b26503ea1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ docs = [ ] lint = [ "ruff>=0.16.1", - "ty>=0.0.35", + "ty==0.0.113", ] testing = [ "libtmux==0.68.0", @@ -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 @@ -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 diff --git a/uv.lock b/uv.lock index a7b733335..6db49c832 100644 --- a/uv.lock +++ b/uv.lock @@ -6,6 +6,9 @@ requires-python = ">=3.12, <4" exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values. exclude-newer-span = "P3D" +[options.exclude-newer-package] +ty = false + [[package]] name = "accessible-pygments" version = "0.0.5" @@ -322,7 +325,7 @@ dev = [ { name = "pytest", specifier = ">=9.2.0,<10" }, { name = "ruff", specifier = ">=0.16.1" }, { name = "sphinx", specifier = ">=9.1.0,<10" }, - { name = "ty", specifier = ">=0.0.35" }, + { name = "ty", specifier = "==0.0.113" }, ] docs = [ { name = "breathe", specifier = ">=4.36.0,<5" }, @@ -331,7 +334,7 @@ docs = [ ] lint = [ { name = "ruff", specifier = ">=0.16.1" }, - { name = "ty", specifier = ">=0.0.35" }, + { name = "ty", specifier = "==0.0.113" }, ] testing = [ { name = "libtmux", specifier = "==0.68.0" }, @@ -755,27 +758,27 @@ wheels = [ [[package]] name = "ty" -version = "0.0.88" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/f5/e8/303e333a45289c2f1f006661c9aa535de83b316a6bfc2d2f97ba815be143/ty-0.0.88.tar.gz", hash = "sha256:5e3165a05b3757edd5a08b1fc6cb4a00c3b067100416d50afb2d13a5ec102206", size = 7968779, upload-time = "2026-10-15T09:41:07.334Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/de/7e/a62ddf5c56cf0f96fdc268bb0ec4bfe16e28b50d9158de8e7038b004e515/ty-0.0.88-py3-none-linux_armv6l.whl", hash = "sha256:19f24e69e97d9edfb05fb2e1c7fe2b6fcce275338415e2f7de23d74627f2b436", size = 14240767, upload-time = "2026-10-15T09:40:23.285Z" }, - { url = "https://files.pythonhosted.org/packages/77/b0/ca23cf93931c6dcf790376c2dac6d2cbcbc1c5fbbead6a536c52eae6ac22/ty-0.0.88-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:957f0db83b9b0f837b86fe4a0a8fb98db8da89444555246871e6eb2820629c1b", size = 13755861, upload-time = "2026-10-15T09:40:26.292Z" }, - { url = "https://files.pythonhosted.org/packages/8c/a6/91d2aa967a69535845445660d3a9412f7f4f746597c650e5d3a799c9e286/ty-0.0.88-py3-none-macosx_11_0_arm64.whl", hash = "sha256:021bd4a6d01d4a39e48a87e308161e7adea851b8cab9f4c71452dde6e365aa15", size = 12771934, upload-time = "2026-10-15T09:40:28.913Z" }, - { url = "https://files.pythonhosted.org/packages/2e/a4/266f2dacbded7fac1f567292363ad05d4d03b246a8bd5ccd68206d0c9ce0/ty-0.0.88-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bcd956e6c3c8b038a3725f2bf255a45a284ece64a012a4e790fbf23db862af84", size = 13638979, upload-time = "2026-10-15T09:40:31.49Z" }, - { url = "https://files.pythonhosted.org/packages/18/c9/4d7ec25675e9d2d70d9a8635d47b4737540818852e35fc6b7ca47b3e7f99/ty-0.0.88-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a8beb5fe8ae4ee8853891647d27cec7b65f6547532e9250cd3439181993aa973", size = 13971852, upload-time = "2026-10-15T09:40:34.039Z" }, - { url = "https://files.pythonhosted.org/packages/57/5d/0753dd860127f2601333156948ce2680ac2f65534ee39c81e9d4623f51aa/ty-0.0.88-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6aa805d8d4ab6512ca9591c221f828d818c000cdd5bd5108923eb21405eefebd", size = 14876774, upload-time = "2026-10-15T09:40:36.86Z" }, - { url = "https://files.pythonhosted.org/packages/26/8b/706b59938c4c83caed1df9a74f9b6d1e9d7d196b5006f3655b618daab5da/ty-0.0.88-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7dfb625a98f8fb02995aa3e3fb762c910158f1419bf38d1d1dcb97f35526e4b0", size = 15249187, upload-time = "2026-10-15T09:40:39.643Z" }, - { url = "https://files.pythonhosted.org/packages/09/1a/1a214f674e66c65347380cc8b637ffbb50624ab4ff7dc0d6f0bf34c64303/ty-0.0.88-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6784a5398c69ea39ad43512ba5fa7850599d8f371b7caa974dc8603b9634e63f", size = 15202315, upload-time = "2026-10-15T09:40:42.436Z" }, - { url = "https://files.pythonhosted.org/packages/e4/9e/a8a0af89ce94e87f6b4fdec62dce473d2858223ba7298276911c568f413c/ty-0.0.88-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ec0c364abad7e81013c1b4ec788d811078b9b20a8a2e07ac8613499eb6f104f", size = 14447671, upload-time = "2026-10-15T09:40:44.842Z" }, - { url = "https://files.pythonhosted.org/packages/17/74/be3cd8bee9ad01615449a1c22c6be2cc9a5d652eb6c1e9b2e993dc8b9141/ty-0.0.88-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:96940e5393ec00732bfaa747825979ebd971f0bafe538538d164bcba4cec5408", size = 14728283, upload-time = "2026-10-15T09:40:47.47Z" }, - { url = "https://files.pythonhosted.org/packages/84/e7/5918d99b7aff20c4a55f50d64620186af822a023ca767b65d965a3fd4858/ty-0.0.88-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:c245fab62af678d3df2e8bf26550c0f81f5567b72de670863e300cab07d0b891", size = 13637751, upload-time = "2026-10-15T09:40:49.832Z" }, - { url = "https://files.pythonhosted.org/packages/c5/df/2eb1ddfafd986fdfa7be9941f2665945fe6dbcc952309195ba536f6394fd/ty-0.0.88-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:90407c5c7e0387295aab0e2d4de0ed7a7942f9793a4628942f367257d431e55c", size = 13985403, upload-time = "2026-10-15T09:40:52.348Z" }, - { url = "https://files.pythonhosted.org/packages/67/12/f9fc5e038dd2f0372be8ffbf5b1e429ef084035efdede5288a6fae74c52f/ty-0.0.88-py3-none-musllinux_1_2_i686.whl", hash = "sha256:591ef09e37bec260399cd526d694a815b8f1dab55dc841a44bd9ccb78cca84a1", size = 14305076, upload-time = "2026-10-15T09:40:54.944Z" }, - { url = "https://files.pythonhosted.org/packages/5e/5a/8a5e7c43b5d981d1f383602ddeaea91e0fde18900d1808ee74e1c894570c/ty-0.0.88-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:092522f2fa87becfb3b098a1f58ec1b82dfd7c87eaa0533c5ce500a743d8e79e", size = 14637327, upload-time = "2026-10-15T09:40:57.462Z" }, - { url = "https://files.pythonhosted.org/packages/5f/16/426272696ea754575305868787b35f18c23a3851c363827f27c7c8093cff/ty-0.0.88-py3-none-win32.whl", hash = "sha256:954cc19cd68015d4e92eb3f9218760d324dbdf67daae0e0da2c0179b644f450f", size = 13178338, upload-time = "2026-10-15T09:41:00.059Z" }, - { url = "https://files.pythonhosted.org/packages/49/a1/db4113fa72d44a28aeeccf3a71f9a803b278d945b11fa7b070a703d8bffd/ty-0.0.88-py3-none-win_amd64.whl", hash = "sha256:c76f1c65a492fed594bc14a1c70a1fdacd8a3165440a1eaa5af7f3c248fee963", size = 13690632, upload-time = "2026-10-15T09:41:02.379Z" }, - { url = "https://files.pythonhosted.org/packages/70/16/bc82e209f0d4de6213d41f58dd619b3e65d24cb58a6da0cd7c6665dd6654/ty-0.0.88-py3-none-win_arm64.whl", hash = "sha256:9b4289f6dec4123cf671a5b3d9512cdbf03889996d6895efc595bdc50573eafc", size = 13251351, upload-time = "2026-10-15T09:41:04.912Z" }, +version = "0.0.113" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d2/4b/7138e0209e6fe108391f05438629db277694ae855ce06e38af139a24bb1f/ty-0.0.113.tar.gz", hash = "sha256:d751c2314a497ff506947908e218a0adbdcb3c560e2783dcd7458660a88d3261", size = 8470296, upload-time = "2026-11-29T02:34:32.062Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/a7/e39420a5374108e4d22b18d8ef47cd3b2b11e8c8bdd835ce78b6911bf860/ty-0.0.113-py3-none-linux_armv6l.whl", hash = "sha256:51329027041bc71b8a4308048909775404b6fc49ab257f5fc56f1251d0252615", size = 15566174, upload-time = "2026-11-29T02:33:45.96Z" }, + { url = "https://files.pythonhosted.org/packages/75/e3/728392a39edd84a73e83ca95cb80a368395f6adfffbdc2bfc76de1a9223f/ty-0.0.113-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:bd6d0faac3c0fa9f5e711f497a7cf448e4f5f189c77638327123ed7469afb446", size = 15075921, upload-time = "2026-11-29T02:33:49.133Z" }, + { url = "https://files.pythonhosted.org/packages/9e/5d/eb84feaf16a5c9d4bcab34eedf107b6ecb9a746ce759e67b244bfbe3afd5/ty-0.0.113-py3-none-macosx_11_0_arm64.whl", hash = "sha256:a617ba0012b21c2984680bcb596f8c78bdc07fb922f811fe2ba0d29169f53581", size = 14594072, upload-time = "2026-11-29T02:33:51.661Z" }, + { url = "https://files.pythonhosted.org/packages/89/87/40de569367a5aaff373d2e5657cd5d1cd0ae9fe90982fd26a900f7122a61/ty-0.0.113-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:48f376e42b5f7b824b4dd8aa421ef91f009b695689625054385280683bb8b19d", size = 15609691, upload-time = "2026-11-29T02:33:54.329Z" }, + { url = "https://files.pythonhosted.org/packages/ff/42/77677c00cabb09c2a122877bc754b94128434bd0461591b3a20c8b3bda67/ty-0.0.113-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4c0e21df96effa906892ea682c28d5bdb784813584b35736f34fb13022ed6c2c", size = 15287631, upload-time = "2026-11-29T02:33:56.917Z" }, + { url = "https://files.pythonhosted.org/packages/e6/01/b4283becd51b637627858faffe80907c054635958806fdfcaf6bd7efb63c/ty-0.0.113-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c67d33ddaec99fb2b01d50725c0ba8f45ea4a2f1ab8b1bd8d72a1cffde4d9166", size = 16281475, upload-time = "2026-11-29T02:33:59.399Z" }, + { url = "https://files.pythonhosted.org/packages/74/3e/4221eafd1cb4f3ef4ce80249d32c5d062e150c4bba0ddb16d2b52eabead0/ty-0.0.113-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c1ac300512ab772c0f9da24f1ac11caa3f961b5b7741f920885ec0c6e6ededca", size = 16735678, upload-time = "2026-11-29T02:34:02.521Z" }, + { url = "https://files.pythonhosted.org/packages/6c/f5/cb4e5a22e830f225e892efe2435799b6128d6c62212e27389feb5b6d2498/ty-0.0.113-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dd6c055511c79d34c720fc03da96c62567a7c866d522ad6aa51357b0bf840f9e", size = 16568976, upload-time = "2026-11-29T02:34:05.122Z" }, + { url = "https://files.pythonhosted.org/packages/e9/7c/ae864be853865350447161808015f6d04e3c8c9f7831fbb64f56a99ec470/ty-0.0.113-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:edf0ff45b103999528ade08e30d9149ef901e1d8f413cc61a1681470c02bc5f2", size = 17319920, upload-time = "2026-11-29T02:34:07.973Z" }, + { url = "https://files.pythonhosted.org/packages/85/92/4a16e1e23210e8e7a6d77d025a505811fec4394de25917c588fe0acd2f63/ty-0.0.113-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:c2f03b32bcde1d3f888082503226f7046cee179f002d84a43d802c43acc64f1c", size = 16145916, upload-time = "2026-11-29T02:34:10.796Z" }, + { url = "https://files.pythonhosted.org/packages/99/38/cd64145da4a8b47e3c3b92cd2d6e2a3909848c053094a6b71376792d7d83/ty-0.0.113-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:445319275f80edcf02a638e7701f715d44731f0c247753dc800cda97c50c30ef", size = 14953053, upload-time = "2026-11-29T02:34:13.318Z" }, + { url = "https://files.pythonhosted.org/packages/78/cf/eff9e15b8a96d1beb4487624eaa9fe192f63585858f89b73d8383f9d62b8/ty-0.0.113-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:62e06dfadb5fd43d57b64e6401731c97005562f321b592cfab1587658999a7ed", size = 15296406, upload-time = "2026-11-29T02:34:16.143Z" }, + { url = "https://files.pythonhosted.org/packages/f3/ea/952ccd2250c06475e6e6563936c98196d74b16220105e4e5cfd3d477abf2/ty-0.0.113-py3-none-musllinux_1_2_i686.whl", hash = "sha256:238aee2c3bde34d12b0753800d0836de16b93f8e0694cec2ba29cc3faed325aa", size = 15640130, upload-time = "2026-11-29T02:34:18.861Z" }, + { url = "https://files.pythonhosted.org/packages/ef/38/0b13a7199197866c16a180f9b6843829d4876d1ef277561a728bb79c758d/ty-0.0.113-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:8a8f2b7f015651d6d1e8100cd3b0bbf7004ffeb4355cb9724e0af44fd40f29c3", size = 15944137, upload-time = "2026-11-29T02:34:21.32Z" }, + { url = "https://files.pythonhosted.org/packages/c7/c9/fab860478f952d6261714fc5be843874a83343b4d5eeb9f651cebb10e1be/ty-0.0.113-py3-none-win32.whl", hash = "sha256:37eafc0cdb484a127e3902ba660e77756d0162b2799ef17d0c9ffdd5c00f8463", size = 14472935, upload-time = "2026-11-29T02:34:24.048Z" }, + { url = "https://files.pythonhosted.org/packages/c1/fa/cd0c051183c4586b350d65ef53d4f761ecde2a8380e48824fd9e65e57b80/ty-0.0.113-py3-none-win_amd64.whl", hash = "sha256:3826ca83e71ef66d94cdc8bc6df8392a38cf2da83be9dcedcf3f3040023dc9cd", size = 15273590, upload-time = "2026-11-29T02:34:26.734Z" }, + { url = "https://files.pythonhosted.org/packages/b6/1c/1bbcc9b44176d56f291e1bc5346f84ff39faf96365d9fbd9799af90bbf23/ty-0.0.113-py3-none-win_arm64.whl", hash = "sha256:aa75bbb54eecf55f6190ff3a1054d9a977d5e04ed597ea11184521ed138e4bb9", size = 14589176, upload-time = "2026-11-29T02:34:29.219Z" }, ] [[package]] From 58f595662e3be79524d0088ddf916f970daa8a98 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 29 Nov 2026 11:45:32 -0600 Subject: [PATCH 2/3] exporter(test) Require the loader and native line anchor why: The fixture expects a loadable exporter module and a source line link. A missing loader or regex match should identify the failed setup. what: - Check the module specification and loader before executing the fixture. - Assert a native line match before reading the matched anchor. --- packages/api-model/test/test_haskell_export.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/api-model/test/test_haskell_export.py b/packages/api-model/test/test_haskell_export.py index a84ab03ea..90d89dc50 100644 --- a/packages/api-model/test/test_haskell_export.py +++ b/packages/api-model/test/test_haskell_export.py @@ -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" @@ -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" ) From efaffbe2a0c956b909416b0209147a10dc3af14a Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 29 Nov 2026 13:11:49 -0600 Subject: [PATCH 3/3] docs(typing) Define when Python inputs may have open types why: Contributors need a consistent way to resolve typing ambiguities while preserving the contract callers rely on. what: - Describe the limited uses of object and Any at input boundaries. - Check precise signatures against supported callers, misuse and downstream inference. --- AGENTS.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 301e38dba..03b3609a3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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)