Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/code-checkers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ jobs:
run: cp vm_data.py-dist vm_data.py
- run: pyright .

ty:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
with:
persist-credentials: false
- uses: ./.github/actions/uv-setup/
- name: Create a dummy data.py
run: cp data.py-dist data.py
- name: Create a dummy vm_data.py
run: cp vm_data.py-dist vm_data.py
- run: ty check .

ruff:
runs-on: ubuntu-latest
env:
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Makefile to run static code checkers locally
# Equivalent to the GitHub Actions workflow in .github/workflows/code-checkers.yml

.PHONY: all mypy pyright ruff flake8
.PHONY: all mypy pyright ruff flake8 ty

all: mypy pyright ruff flake8
all: ruff flake8 ty pyright mypy

data.py:
@test -r data.py || echo "File 'data.py' does not exist. Refer to https://github.com/xcp-ng/xcp-ng-tests#configuration." && exit 1
Expand All @@ -19,3 +19,6 @@ ruff: data.py

flake8:
uv run flake8

ty: data.py
uv run ty check .
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def pytest_runtest_makereport(

# store test results for each phase of a call, which can
# be "setup", "call", "teardown"
item.stash.setdefault(PHASE_REPORT_KEY, {})[rep.when] = rep
item.stash.setdefault(PHASE_REPORT_KEY, {})[rep.when]# = rep

return rep

Expand Down
4 changes: 2 additions & 2 deletions lib/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


ignore_ssh_banner = False
ssh_output_max_lines = 20
ignore_ssh_banner: bool = False
ssh_output_max_lines: int = 20

def sr_device_config(datakey: str, *, required: list[str] = []) -> dict[str, str]:
import data # import here to avoid depending on this user file for collecting tests
Expand Down
2 changes: 1 addition & 1 deletion lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def rescan_block_devices_info(self) -> None:
) # limit to: sd, blkext

self.block_devices_info = [
Host.BlockDeviceInfo({key.lower(): value.strip('"') # type: ignore[misc]
Host.BlockDeviceInfo({key.lower(): value.strip('"') # type: ignore
for key, value in re.findall(r'(\S+)=(".*?"|\S+)', line)})
for line in output_string.strip().splitlines()
]
Expand Down
17 changes: 12 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ dependencies = [
[dependency-groups]
dev = [
"bs4>=0.0.1",
"mypy",
"flake8",
"flake8-pyproject",
"libarchive-c==5.3",
"mypy",
"pydocstyle",
"pyright",
"ruff",
"types-requests",
"typing-extensions",
"libarchive-c==5.3",
"types-pygments",
"ty",
"types-colorama",
"types-pexpect",
"types-pygments",
"types-requests",
"typing-extensions",
"zizmor",
]

Expand All @@ -39,6 +40,9 @@ typeCheckingMode = "standard"
reportMissingParameterType = "error"
reportUnknownParameterType = "error"

[tool.ty.rules]
unused-type-ignore-comment = "ignore"

[tool.ruff]
preview = true
line-length = 120
Expand All @@ -49,6 +53,7 @@ quote-style = "preserve"

[tool.ruff.lint]
select = [
"ANN", # flake8-annotations
"D", # pydocstyle
"FA", # future-annotations
"F", # Pyflakes
Expand All @@ -61,6 +66,7 @@ select = [
]
# don't use some of the default D and SIM rules
ignore = [
"ANN401", # missing-return-type-special-method. Might be removed later.
"D100", # undocumented-public-module
"D101", # undocumented-public-class
"D102", # undocumented-public-method
Expand All @@ -81,6 +87,7 @@ ignore = [
"SIM105", # suppressible-exception
"SIM108", # if-else-block-instead-of-if-exp
]
flake8-annotations.mypy-init-return = true

# restrict to the PEP 257 rules
pydocstyle.convention = "pep257"
Expand Down
11 changes: 6 additions & 5 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# generated with update_requirements.py, do not edit manually
bs4>=0.0.1
mypy
flake8
flake8-pyproject
libarchive-c==5.3
mypy
pydocstyle
pyright
ruff
types-requests
typing-extensions
libarchive-c==5.3
types-pygments
ty
types-colorama
types-pexpect
types-pygments
types-requests
typing-extensions
zizmor
-r base.txt
6 changes: 3 additions & 3 deletions scripts/xva_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ def __init__(self, member: minidom.Element):

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

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

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

Expand Down
26 changes: 26 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading