diff options
author | Michael Schneider <michael.schneider@cyberus-technology.de> | 2022-06-03 13:37:04 +0200 |
---|---|---|
committer | Michael Schneider <michael.schneider@cyberus-technology.de> | 2022-06-03 13:37:04 +0200 |
commit | fd4ebd89909f181b2f88be5ba44a4eb7b6a903ab (patch) | |
tree | 92a648fdc68be69ab56f88906fbd687703918c8f /nixos/lib | |
parent | 814027378bcddb1f885a1a17f0b34b16d7593b54 (diff) |
add opt out flag for type checking
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/testing-python.nix | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index b76ce3bc3226f..8ba2d32ddda54 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -50,6 +50,7 @@ rec { , qemu_pkg ? pkgs.qemu_test , enableOCR ? false , skipLint ? false + , skipTypeCheck ? false , passthru ? {} , interactive ? false }: @@ -129,19 +130,21 @@ rec { vmStartScripts=($(for i in ${toString vms}; do echo $i/bin/run-*-vm; done)) - # prepend type hints so the test script can be type checked with mypy - cat "${./test-script-prepend.py}" >> testScriptWithTypes - echo "${builtins.toString machineNames}" >> testScriptWithTypes - echo "${builtins.toString vlanNames}" >> testScriptWithTypes - echo -n "$testScript" >> testScriptWithTypes - - # set pythonpath so mypy knows where to find the imports. this requires the py.typed file. - export PYTHONPATH='${./test-driver}' - mypy --no-implicit-optional \ - --pretty \ - --no-color-output \ - testScriptWithTypes - unset PYTHONPATH + ${lib.optionalString (!skipTypeCheck) '' + # prepend type hints so the test script can be type checked with mypy + cat "${./test-script-prepend.py}" >> testScriptWithTypes + echo "${builtins.toString machineNames}" >> testScriptWithTypes + echo "${builtins.toString vlanNames}" >> testScriptWithTypes + echo -n "$testScript" >> testScriptWithTypes + + # set pythonpath so mypy knows where to find the imports. this requires the py.typed file. + export PYTHONPATH='${./test-driver}' + mypy --no-implicit-optional \ + --pretty \ + --no-color-output \ + testScriptWithTypes + unset PYTHONPATH + ''} echo -n "$testScript" >> $out/test-script @@ -171,6 +174,7 @@ rec { , testScript , enableOCR ? false , name ? "unnamed" + , skipTypeCheck ? false # Skip linting (mainly intended for faster dev cycles) , skipLint ? false , passthru ? {} @@ -232,13 +236,13 @@ rec { ); driver = setupDriverForTest { - inherit testScript enableOCR skipLint passthru; + inherit testScript enableOCR skipTypeCheck skipLint passthru; testName = name; qemu_pkg = pkgs.qemu_test; nodes = mkNodes pkgs.qemu_test; }; driverInteractive = setupDriverForTest { - inherit testScript enableOCR skipLint passthru; + inherit testScript enableOCR skipTypeCheck skipLint passthru; testName = name; qemu_pkg = pkgs.qemu; nodes = mkNodes pkgs.qemu; |