From 60d813c804548a6b3728c35d1097e5133eeb52fc Mon Sep 17 00:00:00 2001 From: xenia Date: Sat, 6 Jan 2024 19:29:52 +0100 Subject: [PATCH] Add mypy to python flake --- python/.gitignore | 1 + python/flake.nix | 9 +++++++-- python/mypy-config.ini | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 python/mypy-config.ini diff --git a/python/.gitignore b/python/.gitignore index 92b2793..804a636 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -1 +1,2 @@ .direnv +.mypy_cache diff --git a/python/flake.nix b/python/flake.nix index e24da9b..a40d442 100644 --- a/python/flake.nix +++ b/python/flake.nix @@ -9,11 +9,16 @@ flake-utils.lib.eachDefaultSystem (sys: let pkgs = nixpkgs.legacyPackages.${sys}; python = pkgs.python310.withPackages (ps: with ps; [ - matplotlib ipython + pylsp-mypy ]); + cfg = ./mypy-config.ini; in rec { - devShells.default = python; + packages.tychk-watch = pkgs.writeScriptBin "tychk" "echo 'running mypy on change...' ; ${pkgs.watchexec}/bin/watchexec -e py ${python}/bin/mypy --config ${cfg} ${./.}"; + packages.tychk = pkgs.writeScriptBin "tychk" "${python}/bin/mypy ${./.} --config ${cfg}"; + devShells.default = pkgs.mkShell { + packages = [ python ]; + }; } ); } diff --git a/python/mypy-config.ini b/python/mypy-config.ini new file mode 100644 index 0000000..2d5cb9f --- /dev/null +++ b/python/mypy-config.ini @@ -0,0 +1,5 @@ +[mypy] +disallow_untyped_defs = True +disallow_incomplete_defs = True +check_untyped_defs = True +