Skip to content

Commit e7a4233

Browse files
committed
python/ci: add Python type check
We started to use more and more typings. This doesn't force you to write typings but enforces them where they are available. On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
1 parent 0b37d9c commit e7a4233

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
run: nix build -L .#checks.x86_64-linux.pythonFormat
4040
- name: Check Python Lints
4141
run: nix build -L .#checks.x86_64-linux.pythonLint
42+
- name: Check Python Lints
43+
run: nix build -L .#checks.x86_64-linux.pythonTypes
4244
- name: Check Spelling
4345
run: nix build -L .#checks.x86_64-linux.typos
4446
# Run all in case we forgot to add a fine-grained job.

flake.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@
141141
ruff check ./tests
142142
mkdir $out
143143
'';
144+
pythonTypes =
145+
pkgs.runCommand "python-types"
146+
{
147+
nativeBuildInputs = with pkgs; [ pyright ];
148+
}
149+
''
150+
pyright ${cleanSrc}/tests
151+
mkdir $out
152+
'';
144153
typos =
145154
pkgs.runCommand "spellcheck"
146155
{
@@ -167,6 +176,7 @@
167176
deadnix
168177
pythonFormat
169178
pythonLint
179+
pythonTypes
170180
typos
171181
;
172182
default = all;

tests/testscript.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import unittest
77
import weakref
88

9+
# pyright: reportPossiblyUnboundVariable=false
10+
911
# Following is required to allow proper linting of the python code in IDEs.
1012
# Because certain functions like start_all() and certain objects like computeVM
1113
# or other machines are added by Nix, we need to provide certain stub objects
@@ -85,7 +87,8 @@ def __init__(self, command, machine):
8587
:param machine: Virtual machine to send the command from
8688
:type machine: Machine
8789
"""
88-
self._finilizer = weakref.finalize(self, command, machine)
90+
91+
self._finilizer = weakref.finalize(self, command, machine) # pyright: ignore[reportCallIssue]
8992

9093
def __enter__(self):
9194
return self

tests/testscript_long_migration_with_load.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import time
22
import unittest
33

4+
# pyright: reportPossiblyUnboundVariable=false
5+
46
# Following is required to allow proper linting of the python code in IDEs.
57
# Because certain functions like start_all() and certain objects like computeVM
68
# or other machines are added by Nix, we need to provide certain stub objects

0 commit comments

Comments
 (0)