mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Python: run mypy on the tests
This commit is contained in:
parent
c111098e49
commit
607d70b3fa
21 changed files with 169 additions and 69 deletions
|
@ -4,9 +4,10 @@
|
|||
from slint import slint as native
|
||||
import weakref
|
||||
import gc
|
||||
import typing
|
||||
|
||||
|
||||
def test_callback_gc():
|
||||
def test_callback_gc() -> None:
|
||||
compiler = native.Compiler()
|
||||
|
||||
compdef = compiler.build_from_source("""
|
||||
|
@ -17,17 +18,18 @@ def test_callback_gc():
|
|||
""", "").component("Test")
|
||||
assert compdef != None
|
||||
|
||||
instance = compdef.create()
|
||||
instance: native.ComponentInstance | None = compdef.create()
|
||||
assert instance != None
|
||||
|
||||
class Handler:
|
||||
def __init__(self, instance):
|
||||
def __init__(self, instance: native.ComponentInstance) -> None:
|
||||
self.instance = instance
|
||||
|
||||
def python_callback(self, input):
|
||||
return input + instance.get_property("test-value")
|
||||
def python_callback(self, input: str) -> str:
|
||||
return input + typing.cast(str, self.instance.get_property("test-value"))
|
||||
|
||||
handler = Handler(instance)
|
||||
handler: Handler | None = Handler(instance)
|
||||
assert handler is not None
|
||||
instance.set_callback(
|
||||
"test-callback", handler.python_callback)
|
||||
handler = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue