From d36124f2482001bfa99a38a16451bf9a22b18462 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 18 Dec 2025 09:19:19 +0100 Subject: [PATCH] CI: Fix python ty runs with latest ty beta - Add missing cast - Fix unnecessary cast in test_load_file.py --- api/python/slint/build_docs.py | 4 +++- api/python/slint/tests/test_load_file.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/python/slint/build_docs.py b/api/python/slint/build_docs.py index 38589d14cf..478ada18d6 100644 --- a/api/python/slint/build_docs.py +++ b/api/python/slint/build_docs.py @@ -5,11 +5,13 @@ import slint import pdoc import pathlib import subprocess +import typing doc = pdoc.doc.Module(slint) -model_cls = doc.get("Model") +model_cls = typing.cast(pdoc.doc.Class, doc.get("Model")) +assert model_cls is not None for method in model_cls.inherited_members[("builtins", "PyModelBase")]: method.is_inherited = False if not method.name.startswith("_") and method.name != "init_self": diff --git a/api/python/slint/tests/test_load_file.py b/api/python/slint/tests/test_load_file.py index 7e89f9d0dd..8b4f75e987 100644 --- a/api/python/slint/tests/test_load_file.py +++ b/api/python/slint/tests/test_load_file.py @@ -4,7 +4,6 @@ import pytest from slint import load_file, CompileError from pathlib import Path -import typing def base_dir() -> Path: @@ -56,7 +55,7 @@ def test_load_file_fail() -> None: def test_compile_error() -> None: with pytest.raises(CompileError) as excinfo: load_file(base_dir() / "test-file-error.slint") - err = typing.cast(CompileError, excinfo.value) + err = excinfo.value diagnostics = err.diagnostics assert len(diagnostics) == 2 assert diagnostics[0].message == "Unknown type 'garbage'"