This is an automated email from the ASF dual-hosted git repository.

yuqi1129 pushed a commit to branch branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-1.3 by this push:
     new 7b4120944a [Cherry-pick to branch-1.3] [#12660] fix(mcp-server): 
Invoke isort/black console scripts and pin their versions (#12661) (#12663)
7b4120944a is described below

commit 7b4120944a1c4b4b5ed0cdcf3a3fd5a4c9ec443f
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Aug 27 15:45:00 2026 +0800

    [Cherry-pick to branch-1.3] [#12660] fix(mcp-server): Invoke isort/black 
console scripts and pin their versions (#12661) (#12663)
    
    **Cherry-pick Information:**
    - Original commit: 3604c670b27d3deac2b80e53a83c363974dd1fcc
    - Target branch: `branch-1.3`
    - Status: ✅ Clean cherry-pick (no conflicts)
    
    Co-authored-by: Qi Yu <[email protected]>
---
 mcp-server/build.gradle.kts | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/mcp-server/build.gradle.kts b/mcp-server/build.gradle.kts
index fe773fcf62..9bc51ad8e6 100644
--- a/mcp-server/build.gradle.kts
+++ b/mcp-server/build.gradle.kts
@@ -39,13 +39,21 @@ fun getUvExecutable(): String {
   }
 }
 
-val venvPython = when {
+// The formatters are invoked through their console scripts rather than 
`python -m <tool>`:
+// isort 9 no longer ships an `__main__` module, so `python -m isort` cannot 
be executed.
+fun venvExecutable(name: String): String = when {
   System.getProperty("os.name").contains("win", ignoreCase = true) ->
-    venvDir.resolve("Scripts/python.exe").absolutePath
+    venvDir.resolve("Scripts/$name.exe").absolutePath
   else ->
-    venvDir.resolve("bin/python").absolutePath
+    venvDir.resolve("bin/$name").absolutePath
 }
 
+val venvPython = venvExecutable("python")
+
+// Pinned so that a new formatter release cannot change the outcome of the 
format check in CI.
+val blackRequirement = "black==26.5.1"
+val isortRequirement = "isort==9.0.0"
+
 tasks {
   register<Exec>("installUv") {
     group = "python"
@@ -160,7 +168,7 @@ tasks {
     workingDir(pythonProjectDir)
 
     doFirst {
-      commandLine(getUvExecutable(), "pip", "install", "--python", venvPython, 
"black", "isort")
+      commandLine(getUvExecutable(), "pip", "install", "--python", venvPython, 
blackRequirement, isortRequirement)
     }
 
     doLast {
@@ -213,13 +221,13 @@ tasks {
       // Apply isort
       exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "isort", "mcp_server", "tests")
+        commandLine(venvExecutable("isort"), "mcp_server", "tests")
       }
 
       // Apply Black
       exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "black", "mcp_server", "tests")
+        commandLine(venvExecutable("black"), "mcp_server", "tests")
       }
 
       logger.lifecycle("Python formatting applied (isort + Black)")
@@ -234,8 +242,10 @@ tasks {
     doLast {
       val isortExitCode = exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "isort", "--check", "mcp_server", 
"tests")
-        isIgnoreExitValue = false
+        commandLine(venvExecutable("isort"), "--check", "mcp_server", "tests")
+        // Let the exit code reach the check below, so the failure is reported 
with the message
+        // that names the tool instead of a bare Gradle ExecException.
+        isIgnoreExitValue = true
       }.exitValue
 
       if (isortExitCode != 0) {
@@ -244,8 +254,10 @@ tasks {
 
       val blackExitCode = exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "black", "--check", "mcp_server", 
"tests")
-        isIgnoreExitValue = false
+        commandLine(venvExecutable("black"), "--check", "mcp_server", "tests")
+        // Let the exit code reach the check below, so the failure is reported 
with the message
+        // that names the tool instead of a bare Gradle ExecException.
+        isIgnoreExitValue = true
       }.exitValue
 
       if (blackExitCode != 0) {

Reply via email to