mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Python: Run ruff linter
This commit is contained in:
parent
18032e13b4
commit
1fc0c79cbd
11 changed files with 31 additions and 38 deletions
3
.github/workflows/ci.yaml
vendored
3
.github/workflows/ci.yaml
vendored
|
@ -189,6 +189,9 @@ jobs:
|
|||
- name: Run mypy
|
||||
working-directory: api/python
|
||||
run: uv run mypy -p tests -p slint
|
||||
- name: Run ruff linter
|
||||
working-directory: api/python
|
||||
run: uv tool run ruff check
|
||||
|
||||
cpp_test_driver:
|
||||
env:
|
||||
|
|
|
@ -5,13 +5,11 @@ r"""
|
|||
.. include:: ../README.md
|
||||
"""
|
||||
|
||||
from importlib.machinery import ModuleSpec
|
||||
import os
|
||||
import sys
|
||||
from . import slint as native
|
||||
import types
|
||||
import logging
|
||||
import importlib
|
||||
import copy
|
||||
import typing
|
||||
from typing import Any
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
from slint import slint as native
|
||||
from slint import Color, Brush
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
from slint import load_file, CompileError
|
||||
from slint import load_file
|
||||
import slint
|
||||
import os
|
||||
import pytest
|
||||
import typing
|
||||
|
||||
|
||||
def base_dir() -> str:
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
import pytest
|
||||
from slint import slint as native
|
||||
from slint.slint import ValueType
|
||||
|
||||
|
@ -42,7 +41,7 @@ def test_basic_compiler() -> None:
|
|||
assert result.component_names == ["Test"]
|
||||
compdef = result.component("Test")
|
||||
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
assert compdef.name == "Test"
|
||||
|
||||
|
@ -63,19 +62,19 @@ def test_basic_compiler() -> None:
|
|||
|
||||
assert compdef.globals == ["TestGlobal"]
|
||||
|
||||
assert compdef.global_properties("Garbage") == None
|
||||
assert compdef.global_properties("Garbage") is None
|
||||
assert [
|
||||
(name, type) for name, type in compdef.global_properties("TestGlobal").items()
|
||||
] == [("theglobalprop", ValueType.String)]
|
||||
|
||||
assert compdef.global_callbacks("Garbage") == None
|
||||
assert compdef.global_callbacks("Garbage") is None
|
||||
assert compdef.global_callbacks("TestGlobal") == ["globallogic"]
|
||||
|
||||
assert compdef.global_functions("Garbage") == None
|
||||
assert compdef.global_functions("Garbage") is None
|
||||
assert compdef.global_functions("TestGlobal") == ["globalfun"]
|
||||
|
||||
instance = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
|
||||
def test_compiler_build_from_path() -> None:
|
||||
|
|
|
@ -19,10 +19,10 @@ def test_callback_gc() -> None:
|
|||
""",
|
||||
"",
|
||||
).component("Test")
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
instance: native.ComponentInstance | None = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
class Handler:
|
||||
def __init__(self, instance: native.ComponentInstance) -> None:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import pytest
|
||||
from slint import slint as native
|
||||
from slint.slint import ValueType, Image, Color, Brush
|
||||
from slint.slint import Image, Color, Brush
|
||||
import os
|
||||
|
||||
|
||||
|
@ -44,10 +44,10 @@ def test_property_access() -> None:
|
|||
""",
|
||||
os.path.join(os.path.dirname(__file__), "main.slint"),
|
||||
).component("Test")
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
instance = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
with pytest.raises(ValueError, match="no such property"):
|
||||
instance.set_property("nonexistent", 42)
|
||||
|
@ -70,24 +70,24 @@ def test_property_access() -> None:
|
|||
with pytest.raises(ValueError, match="wrong type"):
|
||||
instance.set_property("floatprop", "Blah")
|
||||
|
||||
assert instance.get_property("boolprop") == True
|
||||
assert instance.get_property("boolprop")
|
||||
instance.set_property("boolprop", False)
|
||||
assert instance.get_property("boolprop") == False
|
||||
assert not instance.get_property("boolprop")
|
||||
with pytest.raises(ValueError, match="wrong type"):
|
||||
instance.set_property("boolprop", 0)
|
||||
|
||||
structval = instance.get_property("structprop")
|
||||
assert isinstance(structval, native.PyStruct)
|
||||
assert structval.title == "builtin"
|
||||
assert structval.finished == True
|
||||
assert structval.dash_prop == True
|
||||
assert structval.finished
|
||||
assert structval.dash_prop
|
||||
instance.set_property(
|
||||
"structprop", {"title": "new", "finished": False, "dash_prop": False}
|
||||
)
|
||||
structval = instance.get_property("structprop")
|
||||
assert structval.title == "new"
|
||||
assert structval.finished == False
|
||||
assert structval.dash_prop == False
|
||||
assert not structval.finished
|
||||
assert not structval.dash_prop
|
||||
|
||||
imageval = instance.get_property("imageprop")
|
||||
assert imageval.width == 320
|
||||
|
@ -159,10 +159,10 @@ def test_callbacks() -> None:
|
|||
""",
|
||||
"",
|
||||
).component("Test")
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
instance = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
assert instance.invoke("test-callback", "foo") == "local foo"
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
import pytest
|
||||
from slint import load_file, CompileError
|
||||
import os
|
||||
from typing import cast
|
||||
|
||||
|
||||
def base_dir() -> str:
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
import pytest
|
||||
from slint import slint as native
|
||||
from slint import loader
|
||||
import sys
|
||||
import os
|
||||
|
@ -15,7 +13,7 @@ def test_magic_import() -> None:
|
|||
|
||||
def test_magic_import_path() -> None:
|
||||
oldsyspath = sys.path
|
||||
assert loader.printerdemo == None
|
||||
assert loader.printerdemo is None
|
||||
try:
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
|
||||
instance = loader.demos.printerdemo.ui.printerdemo.MainWindow()
|
||||
|
|
|
@ -33,10 +33,10 @@ def test_model_notify() -> None:
|
|||
""",
|
||||
"",
|
||||
).component("App")
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
instance = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
model = models.ListModel([100, 0])
|
||||
|
||||
|
@ -64,10 +64,10 @@ def test_model_from_list() -> None:
|
|||
""",
|
||||
"",
|
||||
).component("App")
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
instance = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
model = instance.get_property("data")
|
||||
assert model.row_count() == 4
|
||||
|
@ -112,10 +112,10 @@ def test_rust_model_sequence() -> None:
|
|||
""",
|
||||
"",
|
||||
).component("App")
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
instance = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
model = instance.get_property("data")
|
||||
|
||||
|
@ -143,10 +143,10 @@ def test_model_writeback() -> None:
|
|||
""",
|
||||
"",
|
||||
).component("App")
|
||||
assert compdef != None
|
||||
assert compdef is not None
|
||||
|
||||
instance = compdef.create()
|
||||
assert instance != None
|
||||
assert instance is not None
|
||||
|
||||
model = models.ListModel([100, 0])
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
import pytest
|
||||
from slint import slint as native
|
||||
from slint.slint import ValueType
|
||||
from datetime import timedelta
|
||||
|
||||
counter: int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue