From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B838ABB25B for ; Fri, 22 Mar 2024 19:07:36 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A08DAA541 for ; Fri, 22 Mar 2024 19:07:36 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 22 Mar 2024 19:07:36 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CA24241A92 for ; Fri, 22 Mar 2024 19:07:35 +0100 (CET) From: Max Carrara To: pve-devel@lists.proxmox.com Date: Fri, 22 Mar 2024 19:06:24 +0100 Message-Id: <20240322180624.441185-8-m.carrara@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240322180624.441185-1-m.carrara@proxmox.com> References: <20240322180624.441185-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 pve-esxi-import-tools 7/7] use mypy for automatic type checks in Python X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Mar 2024 18:07:36 -0000 This commit adds mypy [0] as build dependency and ensures it is invoked during the package build process. mypy can also be manually invoked via `make lint`. A mypy.ini file [1] is also added to disable errors regarding missing type stubs for pyVmomi and pyVim. [0]: https://www.mypy-lang.org/ [1]: https://mypy.readthedocs.io/en/stable/config_file.html Signed-off-by: Max Carrara --- Changes v1 --> v2: * new (thanks for suggesting to add mypy.ini, Lukas!) Makefile | 13 ++++++++++++- debian/control | 1 + mypy.ini | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 mypy.ini diff --git a/Makefile b/Makefile index 73e7c5e..cc70305 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ BINARY = $(COMPILEDIR)/esxi-folder-fuse SCRIPT = listvms.py CARGO ?= cargo +MYPY ?= mypy .PHONY: all all: $(BINARY) @@ -40,8 +41,17 @@ check: test test: $(CARGO) test $(CARGO_BUILD_ARGS) +.lint-incremental: $(SCRIPT) + $(MYPY) $? + touch "$@" + +.PHONY: lint +lint: $(SCRIPT) + $(MYPY) $(SCRIPT) + touch ".lint-incremental" + .PHONY: install -install: $(BINARY) $(SCRIPT) +install: $(BINARY) $(SCRIPT) .lint-incremental install -m755 -d $(DESTDIR)$(LIBEXECDIR)/pve-esxi-import-tools install -m755 -t $(DESTDIR)$(LIBEXECDIR)/pve-esxi-import-tools $(BINARY) install -m755 -t $(DESTDIR)$(LIBEXECDIR)/pve-esxi-import-tools $(SCRIPT) @@ -55,6 +65,7 @@ $(BUILD_DIR): cp -t $@.tmp -a \ debian \ Makefile \ + mypy.ini \ listvms.py \ Cargo.toml \ src diff --git a/debian/control b/debian/control index 3c12f29..8687d6d 100644 --- a/debian/control +++ b/debian/control @@ -30,6 +30,7 @@ Build-Depends: cargo:native (>= 0.65.0~), librust-tokio-1+rt-multi-thread-dev, librust-tokio-1+time-dev, libstd-rust-dev, + mypy, rustc:native, Maintainer: Proxmox Support Team Standards-Version: 4.6.2 diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..e6724c8 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,8 @@ +[mypy] + +[mypy-pyVmomi] +ignore_missing_imports = True + +[mypy-pyVim.*] +ignore_missing_imports = True + -- 2.39.2