[Mlir-commits] [mlir] f6f2711 - [mlir] Fix copy-pasted docstrings in Python bindings

Alex Zinenko llvmlistbot at llvm.org
Wed Oct 21 00:52:56 PDT 2020


Author: Alex Zinenko
Date: 2020-10-21T09:49:23+02:00
New Revision: f6f27115e622f2cc6b20579e9d7d84c2304091a1

URL: https://github.com/llvm/llvm-project/commit/f6f27115e622f2cc6b20579e9d7d84c2304091a1
DIFF: https://github.com/llvm/llvm-project/commit/f6f27115e622f2cc6b20579e9d7d84c2304091a1.diff

LOG: [mlir] Fix copy-pasted docstrings in Python bindings

Docstrings for `__str__` method in many classes was recycling the constant
string defined for `Type`, without being types themselves. Use proper
docstrings instead. Since they are succint, use string literals instead of
top-level constants to avoid further mistakes.

Differential Revision: https://reviews.llvm.org/D89780

Added: 
    

Modified: 
    mlir/lib/Bindings/Python/IRModules.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bindings/Python/IRModules.cpp b/mlir/lib/Bindings/Python/IRModules.cpp
index b0b24837276c..db8a220c9d31 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -72,9 +72,6 @@ use the dedicated print method, which supports keyword arguments to customize
 behavior.
 )";
 
-static const char kTypeStrDunderDocstring[] =
-    R"(Prints the assembly form of the type.)";
-
 static const char kDumpDocstring[] =
     R"(Dumps a debug representation of the object to stderr.)";
 
@@ -1978,7 +1975,7 @@ void mlir::python::populateIRSubmodule(py::module &m) {
                                printAccum.getUserData());
             return printAccum.join();
           },
-          kTypeStrDunderDocstring);
+          "Returns the assembly form of the operation.");
 
   // Mapping of PyRegion.
   py::class_<PyRegion>(m, "Region")
@@ -2047,9 +2044,9 @@ void mlir::python::populateIRSubmodule(py::module &m) {
                            printAccum.getUserData());
             return printAccum.join();
           },
-          kTypeStrDunderDocstring);
+          "Returns the assembly form of the block.");
 
-  // Mapping of Type.
+  // Mapping of PyAttribute.
   py::class_<PyAttribute>(m, "Attribute")
       .def_property_readonly(
           "context",
@@ -2086,7 +2083,7 @@ void mlir::python::populateIRSubmodule(py::module &m) {
                                printAccum.getUserData());
             return printAccum.join();
           },
-          kTypeStrDunderDocstring)
+          "Returns the assembly form of the Attribute.")
       .def("__repr__", [](PyAttribute &self) {
         // Generally, assembly formats are not printed for __repr__ because
         // this can cause exceptionally long debug output and exceptions.
@@ -2139,7 +2136,7 @@ void mlir::python::populateIRSubmodule(py::module &m) {
   PyStringAttribute::bind(m);
   PyDenseElementsAttribute::bind(m);
 
-  // Mapping of Type.
+  // Mapping of PyType.
   py::class_<PyType>(m, "Type")
       .def_property_readonly(
           "context", [](PyType &self) { return self.getContext().getObject(); },
@@ -2163,7 +2160,7 @@ void mlir::python::populateIRSubmodule(py::module &m) {
                           printAccum.getUserData());
             return printAccum.join();
           },
-          kTypeStrDunderDocstring)
+          "Returns the assembly form of the type.")
       .def("__repr__", [](PyType &self) {
         // Generally, assembly formats are not printed for __repr__ because
         // this can cause exceptionally long debug output and exceptions.


        


More information about the Mlir-commits mailing list