[llvm] [MLGO] Add pytype test (PR #79558)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 00:13:25 PST 2024


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/79558

This patch adds a pytype test to the mlgo-utils lit test suite to prevent regressions in typing while we wait to setup precommit CI for this specific project.

This is somewhat hacky, but is a temporary fix and will be pulled out soonish. It also should only impact the ML buildbots as they are the only ones that should have `pytype` enabled.

>From 17c6147003bf1f0dd5b8ade71a24caf7b48776e2 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Fri, 26 Jan 2024 08:10:17 +0000
Subject: [PATCH] [MLGO] Add pytype test

This patch adds a pytype test to the mlgo-utils lit test suite to
prevent regressions in typing while we wait to setup precommit CI for
this specific project.
---
 llvm/utils/mlgo-utils/mlgo/corpus/__init__.py | 0
 llvm/utils/mlgo-utils/tests/lit.local.cfg     | 8 ++++++++
 llvm/utils/mlgo-utils/tests/pytype.test       | 4 ++++
 3 files changed, 12 insertions(+)
 create mode 100644 llvm/utils/mlgo-utils/mlgo/corpus/__init__.py
 create mode 100644 llvm/utils/mlgo-utils/tests/pytype.test

diff --git a/llvm/utils/mlgo-utils/mlgo/corpus/__init__.py b/llvm/utils/mlgo-utils/mlgo/corpus/__init__.py
new file mode 100644
index 000000000000000..e69de29bb2d1d64
diff --git a/llvm/utils/mlgo-utils/tests/lit.local.cfg b/llvm/utils/mlgo-utils/tests/lit.local.cfg
index a9088750cb58b1e..e5cbf03104c4892 100644
--- a/llvm/utils/mlgo-utils/tests/lit.local.cfg
+++ b/llvm/utils/mlgo-utils/tests/lit.local.cfg
@@ -4,3 +4,11 @@ import sys
 # the entire project has been bumped to 3.8.
 if sys.version_info > (3,8):
     config.available_features.add("python-38")
+
+# TODO(boomanaiden154): Remove this flag once we enable type checking in the
+# precommit CI.
+try:
+    import pytype
+    config.available_features.add("has-pytype")
+except:
+    pass
diff --git a/llvm/utils/mlgo-utils/tests/pytype.test b/llvm/utils/mlgo-utils/tests/pytype.test
new file mode 100644
index 000000000000000..e2d620472305f1d
--- /dev/null
+++ b/llvm/utils/mlgo-utils/tests/pytype.test
@@ -0,0 +1,4 @@
+# REQUIRES: system-linux, has-pytype
+
+# RUN: pytype %S/../mlgo
+# RUN: pytype %S/../tests



More information about the llvm-commits mailing list