diff --git a/Wrapping/Tools/vtkWrapPythonMethodDef.c b/Wrapping/Tools/vtkWrapPythonMethodDef.c
index c6e2892378a3a8f7f9ad6d7cd66f77b6a3bf1e1f..fd5b858b54f71ae42ab00f4d4021c0f70ebea03f 100644
--- a/Wrapping/Tools/vtkWrapPythonMethodDef.c
+++ b/Wrapping/Tools/vtkWrapPythonMethodDef.c
@@ -430,7 +430,21 @@ static void vtkWrapPython_ClassMethodDef(FILE* fp, const char* classname, const
   {
     fprintf(fp,
       "  {\n"
+      "  #if defined(__clang__) && defined(__has_warning)\n"
+      "  #if __has_warning(\"-Wcast-function-type\")\n"
+      "  #pragma clang diagnostic push\n"
+      "  /* This cast is fine because Python knows what is actually happening\n"
+      "   * due to `METH_KEYWORDS`. Ignore the warning.\n"
+      "   */\n"
+      "  #pragma clang diagnostic ignored \"-Wcast-function-type\"\n"
+      "  #endif\n"
+      "  #endif\n"
       "  \"update\",(PyCFunction)static_cast<PyCFunctionWithKeywords>(\n"
+      "  #if defined(__clang__) && defined(__has_warning)\n"
+      "  #if __has_warning(\"-Wcast-function-type\")\n"
+      "  #pragma clang diagnostic pop\n"
+      "  #endif\n"
+      "  #endif\n"
       "  [](PyObject* self, PyObject* args, PyObject* kwargs) -> PyObject*\n"
       "  {\n"
       "    vtkPythonArgs ap(self, args, \"update\");\n"