Skip to content

Commit 93d5622

Browse files
committed
Support ty as type checker
ty is much faster than pyright or mypy. It's not able to detect the missing typehints on arguments and return values, but fortunately ruff has that feature. Pytest is updated to 9.0.2 to fix the type error on pytest.fail, pytest.xfail and pytest.skip. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 840fcf5 commit 93d5622

File tree

6 files changed

+55
-8
lines changed

6 files changed

+55
-8
lines changed

.github/workflows/code-checkers.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ jobs:
3131
run: cp vm_data.py-dist vm_data.py
3232
- run: pyright .
3333

34+
ty:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
38+
with:
39+
persist-credentials: false
40+
- uses: ./.github/actions/uv-setup/
41+
- name: Create a dummy data.py
42+
run: cp data.py-dist data.py
43+
- name: Create a dummy vm_data.py
44+
run: cp vm_data.py-dist vm_data.py
45+
- run: ty check .
46+
3447
ruff:
3548
runs-on: ubuntu-latest
3649
env:

lib/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

3-
ignore_ssh_banner = False
4-
ssh_output_max_lines = 20
3+
ignore_ssh_banner: bool = False
4+
ssh_output_max_lines: int = 20
55

66
def sr_device_config(datakey: str, *, required: list[str] = []) -> dict[str, str]:
77
import data # import here to avoid depending on this user file for collecting tests

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ dev = [
3131
"types-pygments",
3232
"types-colorama",
3333
"types-pexpect",
34+
"ty",
3435
]
3536

3637
[tool.pyright]
3738
typeCheckingMode = "standard"
3839
reportMissingParameterType = "error"
3940
reportUnknownParameterType = "error"
4041

42+
[tool.ty.rules]
43+
unused-type-ignore-comment = "ignore"
44+
4145
[tool.ruff]
4246
preview = true
4347
line-length = 120
@@ -53,9 +57,11 @@ select = [
5357
"I", # isort
5458
"SLF", # flake8-self
5559
"SIM", # flake8-simplify
60+
"ANN", # flake8-annotations
5661
]
5762
# don't use some of the default D and SIM rules
5863
ignore = [
64+
"ANN401", # missing-return-type-special-method. Might be removed later.
5965
"D100", # undocumented-public-module
6066
"D101", # undocumented-public-class
6167
"D102", # undocumented-public-method
@@ -76,6 +82,7 @@ ignore = [
7682
"SIM105", # suppressible-exception
7783
"SIM108", # if-else-block-instead-of-if-exp
7884
]
85+
flake8-annotations.mypy-init-return = true
7986

8087
# restrict to the PEP 257 rules
8188
pydocstyle.convention = "pep257"

requirements/dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ libarchive-c==5.3
1212
types-pygments
1313
types-colorama
1414
types-pexpect
15+
ty
1516
-r base.txt

scripts/xva_bridge.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ def __init__(self, member: minidom.Element):
1919

2020
def get_name(self) -> str | None:
2121
for child in self.member.childNodes:
22-
if child.nodeType == minidom.Node.ELEMENT_NODE and child.tagName == "name" and child.firstChild:
22+
if isinstance(child, minidom.Element) and child.tagName == "name" and child.firstChild:
2323
return child.firstChild.nodeValue
2424
return None
2525

2626
def get_value(self) -> str | None:
2727
for child in self.member.childNodes:
28-
if child.nodeType == minidom.Node.ELEMENT_NODE and child.tagName == "value" and child.firstChild:
28+
if isinstance(child, minidom.Element) and child.tagName == "value" and child.firstChild:
2929
return child.firstChild.nodeValue
3030
return None
3131

3232
def set_value(self, value: str) -> None:
3333
for child in self.member.childNodes:
34-
if child.nodeType == minidom.Node.ELEMENT_NODE and child.tagName == "value" and child.firstChild:
34+
if isinstance(child, minidom.Element) and child.tagName == "value" and child.firstChild:
3535
child.firstChild.nodeValue = value # type: ignore
3636
return None
3737

uv.lock

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)