]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Added a few docstrings on types registry
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 21 Jan 2021 03:04:09 +0000 (04:04 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 22 Jan 2021 03:11:34 +0000 (04:11 +0100)
psycopg3/psycopg3/oids.py

index 5a54eca83a1003c543fd32e2bb97e6cfb64e4ba1..a30b52f72eaf2b8f0f6b0493c14125e7685a20da 100644 (file)
@@ -61,6 +61,13 @@ class TypesRegistry:
                 yield t
 
     def __getitem__(self, key: Union[str, int]) -> TypeInfo:
+        """
+        Return info about a type, specified by name or oid
+
+        The type name or oid may refer to the array too.
+
+        Raise KeyError if not found.
+        """
         if isinstance(key, str):
             if key.endswith("[]"):
                 key = key[:-2]
@@ -73,12 +80,26 @@ class TypesRegistry:
             )
 
     def get(self, key: Union[str, int]) -> Optional[TypeInfo]:
+        """
+        Return info about a type, specified by name or oid
+
+        The type name or oid may refer to the array too.
+
+        Return None if not found.
+        """
         try:
             return self[key]
         except KeyError:
             return None
 
     def get_oid(self, name: str) -> int:
+        """
+        Return the oid of a PostgreSQL type by name.
+
+        Return the array oid if the type ends with "[]"
+
+        Raise KeyError if the name is unknown.
+        """
         t = self[name]
         if name.endswith("[]"):
             return t.array_oid