public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Max Carrara <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 pve-esxi-import-tools 7/7] use mypy for automatic type checks in Python
Date: Fri, 22 Mar 2024 19:06:24 +0100	[thread overview]
Message-ID: <20240322180624.441185-8-m.carrara@proxmox.com> (raw)
In-Reply-To: <20240322180624.441185-1-m.carrara@proxmox.com>

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 <m.carrara@proxmox.com>
---
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 <support@proxmox.com>
 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





  parent reply	other threads:[~2024-03-22 18:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 18:06 [pve-devel] [PATCH v2 pve-esxi-import-tools 0/7] Improve listvms.py Max Carrara
2024-03-22 18:06 ` [pve-devel] [PATCH v2 pve-esxi-import-tools 1/7] listvms: remove unused import and variable Max Carrara
2024-03-22 18:06 ` [pve-devel] [PATCH v2 pve-esxi-import-tools 2/7] listvms: reorder imports Max Carrara
2024-03-22 18:06 ` [pve-devel] [PATCH v2 pve-esxi-import-tools 3/7] listvms: improve typing and add dataclasses to represent dicts Max Carrara
2024-03-22 18:06 ` [pve-devel] [PATCH v2 pve-esxi-import-tools 4/7] listvms: add arg parser, context manager for connections, fetch helper Max Carrara
2024-03-22 18:06 ` [pve-devel] [PATCH v2 pve-esxi-import-tools 5/7] listvms: dump json directly to stdout Max Carrara
2024-03-22 18:06 ` [pve-devel] [PATCH v2 pve-esxi-import-tools 6/7] listvms: run formatter Max Carrara
2024-03-22 18:06 ` Max Carrara [this message]
2024-03-27 10:50 ` [pve-devel] applied-series: [PATCH v2 pve-esxi-import-tools 0/7] Improve listvms.py Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240322180624.441185-8-m.carrara@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal