public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC 0/2] black, isort, and flake8 configuration
@ 2023-10-04 16:58 Tom Tromey
  2023-10-04 16:58 ` [RFC 1/2] libstdc++: Use 'black' and 'isort' in pretty printers Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Tromey @ 2023-10-04 16:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++

This short series adds configuration files for black ("opinionated"
code formatter), isort (import sorter) and flake8 (Python lint) to
libstdc++.

I marked it as RFC since sometimes people don't like black's output.
In gdb we use it -- at first I found some of its decisions a little
odd, but overall it's nice not to have to review for or worry about
the minitia of code formatting.

Tom



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC 1/2] libstdc++: Use 'black' and 'isort' in pretty printers
  2023-10-04 16:58 [RFC 0/2] black, isort, and flake8 configuration Tom Tromey
@ 2023-10-04 16:58 ` Tom Tromey
  2023-10-04 16:58 ` [RFC 2/2] libstdc++: Add flake8 configuration Tom Tromey
  2024-04-04 13:32 ` [RFC 0/2] black, isort, and " Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2023-10-04 16:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Tom Tromey

This changes libstdc++ to use the 'black' Python formatter.  This
formatter is somewhat standard and fairly comprehensive.  FWIW we use
this in gdb, mainly because it means we don't have to review Python
code for formatting style.

This patch also runs 'isort', which handles sorting the imports.

A new pyproject.tom file is added, so after this you can:

    cd .../libstdc++/python
    black .
    isort .

... and have any changes reformatted.

libstdc++-v3/ChangeLog:
	* pyproject.toml: New file.
	* python/libstdcxx/v6/printers.py: Reformat.
	* python/libstdcxx/v6/xmethods.py: Reformat.
	* python/libstdcxx/v6/__init__.py: Reformat.
---
 libstdc++-v3/python/libstdcxx/v6/__init__.py |   5 +
 libstdc++-v3/python/libstdcxx/v6/printers.py | 834 ++++++++++++-------
 libstdc++-v3/python/libstdcxx/v6/xmethods.py | 138 +--
 libstdc++-v3/python/pyproject.toml           |   6 +
 4 files changed, 648 insertions(+), 335 deletions(-)
 create mode 100644 libstdc++-v3/python/pyproject.toml

diff --git a/libstdc++-v3/python/libstdcxx/v6/__init__.py b/libstdc++-v3/python/libstdcxx/v6/__init__.py
index 8b2cbc60a1b..cb0abf38e6b 100644
--- a/libstdc++-v3/python/libstdcxx/v6/__init__.py
+++ b/libstdc++-v3/python/libstdcxx/v6/__init__.py
@@ -13,19 +13,24 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+
 # Load the xmethods if GDB supports them.
 def gdb_has_xmethods():
     try:
         import gdb.xmethod
+
         return True
     except ImportError:
         return False
 
+
 def register_libstdcxx_printers(obj):
     # Load the pretty-printers.
     from .printers import register_libstdcxx_printers
+
     register_libstdcxx_printers(obj)
 
     if gdb_has_xmethods():
         from .xmethods import register_libstdcxx_xmethods
+
         register_libstdcxx_xmethods(obj)
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 7e16a49aeb0..e26b8b36013 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -15,12 +15,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import gdb
+import datetime
+import errno
 import itertools
 import re
 import sys
-import errno
-import datetime
+
+import gdb
 
 # Python 2 + Python 3 compatibility code
 
@@ -78,6 +79,7 @@ else:
 
         def dst(self, dt):
             return datetime.timedelta(0)
+
     _utc_timezone = UTC()
 
 # Try to use the new-style pretty-printing if available.
@@ -91,6 +93,7 @@ except ImportError:
 _use_type_printing = False
 try:
     import gdb.types
+
     if hasattr(gdb.types, 'TypePrinter'):
         _use_type_printing = True
 except ImportError:
@@ -148,6 +151,7 @@ def lookup_templ_spec(templ, *args):
                 pass
         raise e
 
+
 # Use this to find container node types instead of find_type,
 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91997 for details.
 def lookup_node_type(nodename, containertype):
@@ -177,8 +181,9 @@ def lookup_node_type(nodename, containertype):
     except gdb.error:
         # For debug mode containers the node is in std::__cxx1998.
         if is_member_of_namespace(nodename, 'std'):
-            if is_member_of_namespace(containertype, 'std::__cxx1998',
-                                      'std::__debug', '__gnu_debug'):
+            if is_member_of_namespace(
+                containertype, 'std::__cxx1998', 'std::__debug', '__gnu_debug'
+            ):
                 nodename = nodename.replace('::', '::__cxx1998::', 1)
                 try:
                     return lookup_templ_spec(nodename, valtype)
@@ -296,7 +301,9 @@ class SharedPointerPrinter(printer_base):
                 state = 'expired, weak count %d' % weakcount
             else:
                 state = 'use count %d, weak count %d' % (
-                    usecount, weakcount - 1)
+                    usecount,
+                    weakcount - 1,
+                )
         return '%s<%s> (%s)' % (self._typename, targ, state)
 
 
@@ -305,13 +312,15 @@ def _tuple_impl_get(val):
     bases = val.type.fields()
     if not bases[-1].is_base_class:
         raise ValueError(
-            "Unsupported implementation for std::tuple: %s" % str(val.type))
+            "Unsupported implementation for std::tuple: %s" % str(val.type)
+        )
     # Get the _Head_base<N, T> base class:
     head_base = val.cast(bases[-1].type)
     fields = head_base.type.fields()
     if len(fields) == 0:
         raise ValueError(
-            "Unsupported implementation for std::tuple: %s" % str(val.type))
+            "Unsupported implementation for std::tuple: %s" % str(val.type)
+        )
     if fields[0].name == '_M_head_impl':
         # The tuple element is the _Head_base::_M_head_impl data member.
         return head_base['_M_head_impl']
@@ -321,7 +330,8 @@ def _tuple_impl_get(val):
         return head_base.cast(fields[0].type)
     else:
         raise ValueError(
-            "Unsupported implementation for std::tuple: %s" % str(val.type))
+            "Unsupported implementation for std::tuple: %s" % str(val.type)
+        )
 
 
 def tuple_get(n, val):
@@ -345,14 +355,16 @@ def unique_ptr_get(val):
     # or within a data member of type __uniq_ptr_data.
     impl_type = val.type.fields()[0].type.strip_typedefs()
     # Check for new implementations first:
-    if is_specialization_of(impl_type, '__uniq_ptr_data') \
-            or is_specialization_of(impl_type, '__uniq_ptr_impl'):
+    if is_specialization_of(
+        impl_type, '__uniq_ptr_data'
+    ) or is_specialization_of(impl_type, '__uniq_ptr_impl'):
         tuple_member = val['_M_t']['_M_t']
     elif is_specialization_of(impl_type, 'tuple'):
         tuple_member = val['_M_t']
     else:
         raise ValueError(
-            "Unsupported implementation for unique_ptr: %s" % str(impl_type))
+            "Unsupported implementation for unique_ptr: %s" % str(impl_type)
+        )
     return tuple_get(0, tuple_member)
 
 
@@ -438,9 +450,12 @@ class NodeIteratorPrinter(printer_base):
 
     def to_string(self):
         if not self._val['_M_node']:
-            return 'non-dereferenceable iterator for std::%s' % (self._contname)
-        node = self._val['_M_node'].cast(
-            self._nodetype.pointer()).dereference()
+            return 'non-dereferenceable iterator for std::%s' % (
+                self._contname
+            )
+        node = (
+            self._val['_M_node'].cast(self._nodetype.pointer()).dereference()
+        )
         return str(get_value_from_list_node(node))
 
 
@@ -455,8 +470,9 @@ class StdFwdListIteratorPrinter(NodeIteratorPrinter):
     """Print std::forward_list::iterator."""
 
     def __init__(self, typename, val):
-        NodeIteratorPrinter.__init__(self, typename, val, 'forward_list',
-                                     '_Fwd_list_node')
+        NodeIteratorPrinter.__init__(
+            self, typename, val, 'forward_list', '_Fwd_list_node'
+        )
 
 
 class StdSlistPrinter(printer_base):
@@ -503,8 +519,11 @@ class StdSlistIteratorPrinter(printer_base):
         if not self._val['_M_node']:
             return 'non-dereferenceable iterator for __gnu_cxx::slist'
         nodetype = lookup_node_type(
-            '__gnu_cxx::_Slist_node', self._val.type).pointer()
-        return str(self._val['_M_node'].cast(nodetype).dereference()['_M_data'])
+            '__gnu_cxx::_Slist_node', self._val.type
+        ).pointer()
+        return str(
+            self._val['_M_node'].cast(nodetype).dereference()['_M_data']
+        )
 
 
 class StdVectorPrinter(printer_base):
@@ -550,13 +569,16 @@ class StdVectorPrinter(printer_base):
     def __init__(self, typename, val):
         self._typename = strip_versioned_namespace(typename)
         self._val = val
-        self._is_bool = val.type.template_argument(
-            0).code == gdb.TYPE_CODE_BOOL
+        self._is_bool = (
+            val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL
+        )
 
     def children(self):
-        return self._iterator(self._val['_M_impl']['_M_start'],
-                              self._val['_M_impl']['_M_finish'],
-                              self._is_bool)
+        return self._iterator(
+            self._val['_M_impl']['_M_start'],
+            self._val['_M_impl']['_M_finish'],
+            self._is_bool,
+        )
 
     def to_string(self):
         start = self._val['_M_impl']['_M_start']
@@ -570,11 +592,17 @@ class StdVectorPrinter(printer_base):
             bl = 8 * itype.sizeof
             length = bl * (finish - start) + fo
             capacity = bl * (end - start)
-            return ('%s<bool> of length %d, capacity %d'
-                    % (self._typename, int(length), int(capacity)))
+            return '%s<bool> of length %d, capacity %d' % (
+                self._typename,
+                int(length),
+                int(capacity),
+            )
         else:
-            return ('%s of length %d, capacity %d'
-                    % (self._typename, int(finish - start), int(end - start)))
+            return '%s of length %d, capacity %d' % (
+                self._typename,
+                int(finish - start),
+                int(end - start),
+            )
 
     def display_hint(self):
         return 'array'
@@ -601,8 +629,9 @@ class StdBitIteratorPrinter(printer_base):
     def to_string(self):
         if not self._val['_M_p']:
             return 'non-dereferenceable iterator for std::vector<bool>'
-        return bool(self._val['_M_p'].dereference()
-                    & (1 << self._val['_M_offset']))
+        return bool(
+            self._val['_M_p'].dereference() & (1 << self._val['_M_offset'])
+        )
 
 
 class StdBitReferencePrinter(printer_base):
@@ -631,7 +660,8 @@ class StdTuplePrinter(printer_base):
             elif len(nodes) == 0:
                 return False
             raise ValueError(
-                "Top of tuple tree does not consist of a single node.")
+                "Top of tuple tree does not consist of a single node."
+            )
 
         def __init__(self, head):
             self._head = head
@@ -659,7 +689,8 @@ class StdTuplePrinter(printer_base):
             # Check that this iteration has an expected structure.
             if len(nodes) > 2:
                 raise ValueError(
-                    "Cannot parse more than 2 nodes in a tuple tree.")
+                    "Cannot parse more than 2 nodes in a tuple tree."
+                )
 
             if len(nodes) == 1:
                 # This is the last node of a GCC 5+ std::tuple.
@@ -713,8 +744,10 @@ class StdStackOrQueuePrinter(printer_base):
         return self._visualizer.children()
 
     def to_string(self):
-        return '%s wrapping: %s' % (self._typename,
-                                    self._visualizer.to_string())
+        return '%s wrapping: %s' % (
+            self._typename,
+            self._visualizer.to_string(),
+        )
 
     def display_hint(self):
         if hasattr(self._visualizer, 'display_hint'):
@@ -777,6 +810,7 @@ def get_value_from_Rb_tree_node(node):
         pass
     raise ValueError("Unsupported implementation for %s" % str(node.type))
 
+
 # This is a pretty printer for std::_Rb_tree_iterator (which is
 # std::map::iterator), and has nothing to do with the RbtreeIterator
 # class above.
@@ -852,8 +886,10 @@ class StdMapPrinter(printer_base):
         self._val = val
 
     def to_string(self):
-        return '%s with %s' % (self._typename,
-                               num_elements(len(RbtreeIterator(self._val))))
+        return '%s with %s' % (
+            self._typename,
+            num_elements(len(RbtreeIterator(self._val))),
+        )
 
     def children(self):
         node = lookup_node_type('_Rb_tree_node', self._val.type).pointer()
@@ -891,8 +927,10 @@ class StdSetPrinter(printer_base):
         self._val = val
 
     def to_string(self):
-        return '%s with %s' % (self._typename,
-                               num_elements(len(RbtreeIterator(self._val))))
+        return '%s with %s' % (
+            self._typename,
+            num_elements(len(RbtreeIterator(self._val))),
+        )
 
     def children(self):
         node = lookup_node_type('_Rb_tree_node', self._val.type).pointer()
@@ -1004,8 +1042,13 @@ class StdDequePrinter(printer_base):
     def children(self):
         start = self._val['_M_impl']['_M_start']
         end = self._val['_M_impl']['_M_finish']
-        return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'],
-                          end['_M_cur'], self._buffer_size)
+        return self._iter(
+            start['_M_node'],
+            start['_M_cur'],
+            start['_M_last'],
+            end['_M_cur'],
+            self._buffer_size,
+        )
 
     def display_hint(self):
         return 'array'
@@ -1104,7 +1147,9 @@ class StdStringStreamPrinter(printer_base):
     def to_string(self):
         if self._was_redirected:
             return "%s redirected to %s" % (
-                self._typename, self._streambuf.dereference())
+                self._typename,
+                self._streambuf.dereference(),
+            )
         return self._val['_M_stringbuf']
 
     def display_hint(self):
@@ -1150,8 +1195,11 @@ class StdHashtableIterator(Iterator):
         self._node = hashtable['_M_before_begin']['_M_nxt']
         valtype = hashtable.type.template_argument(1)
         cached = hashtable.type.template_argument(9).template_argument(0)
-        node_type = lookup_templ_spec('std::__detail::_Hash_node', str(valtype),
-                                      'true' if cached else 'false')
+        node_type = lookup_templ_spec(
+            'std::__detail::_Hash_node',
+            str(valtype),
+            'true' if cached else 'false',
+        )
         self._node_type = node_type.pointer()
 
     def __iter__(self):
@@ -1229,11 +1277,13 @@ class Tr1UnorderedMapPrinter(printer_base):
         # Map over the hash table and flatten the result.
         if self._typename.startswith('std::tr1'):
             data = self._flatten(
-                imap(self._format_one, Tr1HashtableIterator(self._hashtable())))
+                imap(self._format_one, Tr1HashtableIterator(self._hashtable()))
+            )
             # Zip the two iterators together.
             return izip(counter, data)
         data = self._flatten(
-            imap(self._format_one, StdHashtableIterator(self._hashtable())))
+            imap(self._format_one, StdHashtableIterator(self._hashtable()))
+        )
         # Zip the two iterators together.
         return izip(counter, data)
 
@@ -1291,8 +1341,9 @@ class SingleObjContainerPrinter(printer_base):
         global _use_type_printing
         if not _use_type_printing:
             return str(type)
-        return gdb.types.apply_type_recognizers(gdb.types.get_type_recognizers(),
-                                                type) or str(type)
+        return gdb.types.apply_type_recognizers(
+            gdb.types.get_type_recognizers(), type
+        ) or str(type)
 
     class _contained(Iterator):
         def __init__(self, val):
@@ -1316,8 +1367,9 @@ class SingleObjContainerPrinter(printer_base):
         return self._contained(self._contained_value)
 
     def display_hint(self):
-        if (hasattr(self._visualizer, 'children')
-                and hasattr(self._visualizer, 'display_hint')):
+        if hasattr(self._visualizer, 'children') and hasattr(
+            self._visualizer, 'display_hint'
+        ):
             # If contained value is a map we want to display in the same way.
             return self._visualizer.display_hint()
         return self._hint
@@ -1352,8 +1404,12 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
 
     def __init__(self, typename, val):
         self._typename = strip_versioned_namespace(typename)
-        self._typename = re.sub(r'^std::experimental::fundamentals_v\d::',
-                                'std::experimental::', self._typename, 1)
+        self._typename = re.sub(
+            r'^std::experimental::fundamentals_v\d::',
+            'std::experimental::',
+            self._typename,
+            1,
+        )
         self._val = val
         self._contained_type = None
         contained_value = None
@@ -1363,7 +1419,8 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
             func = function_pointer_to_name(mgr)
             if not func:
                 raise ValueError(
-                    "Invalid function pointer in %s" % (self._typename))
+                    "Invalid function pointer in %s" % (self._typename)
+                )
             # We want to use this regular expression:
             # T::_Manager_xxx<.*>::_S_manage\(T::_Op, const T\*, T::_Arg\*\)
             # where T is std::any or std::experimental::any.
@@ -1377,7 +1434,8 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
             m = re.match(rx, func)
             if not m:
                 raise ValueError(
-                    "Unknown manager function in %s" % self._typename)
+                    "Unknown manager function in %s" % self._typename
+                )
 
             mgrname = m.group(1)
             # FIXME need to expand 'std::string' so that gdb.lookup_type works
@@ -1413,9 +1471,11 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
                 valptr = self._val['_M_storage']['_M_ptr']
             else:
                 raise ValueError(
-                    "Unknown manager function in %s" % self._typename)
+                    "Unknown manager function in %s" % self._typename
+                )
             contained_value = valptr.cast(
-                self._contained_type.pointer()).dereference()
+                self._contained_type.pointer()
+            ).dereference()
             visualizer = gdb.default_visualizer(contained_value)
         super(StdExpAnyPrinter, self).__init__(contained_value, visualizer)
 
@@ -1436,8 +1496,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
         strings = {str(gdb.lookup_type('std::string').strip_typedefs())}
         # So also consider all the other possible std::string types!
         s = 'basic_string<char, std::char_traits<char>, std::allocator<char> >'
-        quals = ['std::', 'std::__cxx11::',
-                 'std::' + _versioned_namespace]
+        quals = ['std::', 'std::__cxx11::', 'std::' + _versioned_namespace]
         strings |= {q + s for q in quals}  # set of unique strings
         return strings
 
@@ -1449,7 +1508,10 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter):
         typename = strip_versioned_namespace(typename)
         self._typename = re.sub(
             r'^std::(experimental::|)(fundamentals_v\d::|)(.*)',
-            r'std::\1\3', typename, 1)
+            r'std::\1\3',
+            typename,
+            1,
+        )
         payload = val['_M_payload']
         if self._typename.startswith('std::experimental'):
             engaged = val['_M_engaged']
@@ -1466,14 +1528,17 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter):
         if not engaged:
             contained_value = None
         super(StdExpOptionalPrinter, self).__init__(
-            contained_value, visualizer)
+            contained_value, visualizer
+        )
 
     def to_string(self):
         if self._contained_value is None:
             return "%s [no contained value]" % self._typename
         if hasattr(self._visualizer, 'children'):
-            return "%s containing %s" % (self._typename,
-                                         self._visualizer.to_string())
+            return "%s containing %s" % (
+                self._typename,
+                self._visualizer.to_string(),
+            )
         return self._typename
 
 
@@ -1492,17 +1557,22 @@ class StdVariantPrinter(SingleObjContainerPrinter):
             self._contained_type = alternatives[int(self._index)]
             addr = val['_M_u']['_M_first']['_M_storage'].address
             contained_value = addr.cast(
-                self._contained_type.pointer()).dereference()
+                self._contained_type.pointer()
+            ).dereference()
             visualizer = gdb.default_visualizer(contained_value)
         super(StdVariantPrinter, self).__init__(
-            contained_value, visualizer, 'array')
+            contained_value, visualizer, 'array'
+        )
 
     def to_string(self):
         if self._contained_value is None:
             return "%s [no contained value]" % self._typename
         if hasattr(self._visualizer, 'children'):
-            return "%s [index %d] containing %s" % (self._typename, self._index,
-                                                    self._visualizer.to_string())
+            return "%s [index %d] containing %s" % (
+                self._typename,
+                self._index,
+                self._visualizer.to_string(),
+            )
         return "%s [index %d]" % (self._typename, self._index)
 
 
@@ -1513,24 +1583,30 @@ class StdNodeHandlePrinter(SingleObjContainerPrinter):
         self._value_type = val.type.template_argument(1)
         nodetype = val.type.template_argument(2).template_argument(0)
         self._is_rb_tree_node = is_specialization_of(
-            nodetype.name, '_Rb_tree_node')
+            nodetype.name, '_Rb_tree_node'
+        )
         self._is_map_node = val.type.template_argument(0) != self._value_type
         nodeptr = val['_M_ptr']
         if nodeptr:
             if self._is_rb_tree_node:
                 contained_value = get_value_from_Rb_tree_node(
-                    nodeptr.dereference())
+                    nodeptr.dereference()
+                )
             else:
-                contained_value = get_value_from_aligned_membuf(nodeptr['_M_storage'],
-                                                                self._value_type)
+                contained_value = get_value_from_aligned_membuf(
+                    nodeptr['_M_storage'], self._value_type
+                )
             visualizer = gdb.default_visualizer(contained_value)
         else:
             contained_value = None
             visualizer = None
         optalloc = val['_M_alloc']
-        self._alloc = optalloc['_M_payload'] if optalloc['_M_engaged'] else None
-        super(StdNodeHandlePrinter, self).__init__(contained_value, visualizer,
-                                                   'array')
+        self._alloc = (
+            optalloc['_M_payload'] if optalloc['_M_engaged'] else None
+        )
+        super(StdNodeHandlePrinter, self).__init__(
+            contained_value, visualizer, 'array'
+        )
 
     def to_string(self):
         desc = 'node handle for '
@@ -1662,7 +1738,7 @@ class StdPathPrinter(printer_base):
                 char_type = gdb.lookup_type('char')
                 impl = impl.cast(int_type.pointer())
                 size = impl.dereference()
-                #self._capacity = (impl + 1).dereference()
+                # self._capacity = (impl + 1).dereference()
                 if hasattr(gdb.Type, 'alignof'):
                     sizeof_Impl = max(2 * int_type.sizeof, cmpt_type.alignof)
                 else:
@@ -1732,7 +1808,7 @@ class StdCmpCatPrinter(printer_base):
     """Print a comparison category object."""
 
     def __init__(self, typename, val):
-        self._typename = typename[typename.rfind(':') + 1:]
+        self._typename = typename[typename.rfind(':') + 1 :]
         self._val = val['_M_value']
 
     def to_string(self):
@@ -1756,6 +1832,7 @@ class StdErrorCodePrinter(printer_base):
         if StdErrorCodePrinter._system_is_posix is None:
             try:
                 import posix
+
                 StdErrorCodePrinter._system_is_posix = True
             except ImportError:
                 StdErrorCodePrinter._system_is_posix = False
@@ -1846,8 +1923,10 @@ class StdErrorCodePrinter(printer_base):
         cat = self._val['_M_cat']
         name, alt_name, enum, is_errno = self._category_info(cat)
         if value == 0:
-            default_cats = {'error_code': 'system',
-                            'error_condition': 'generic'}
+            default_cats = {
+                'error_code': 'system',
+                'error_condition': 'generic',
+            }
             if name == default_cats[self._unqualified_name(self._typename)]:
                 return self._typename + ' = { }'  # default-constructed value
 
@@ -1880,14 +1959,21 @@ class StdRegexStatePrinter(printer_base):
             opcode = opcode[25:]
         next_id = self._val['_M_next']
 
-        variants = {'repeat': 'alt', 'alternative': 'alt',
-                    'subexpr_begin': 'subexpr', 'subexpr_end': 'subexpr',
-                    'line_begin_assertion': None, 'line_end_assertion': None,
-                    'word_boundary': 'neg', 'subexpr_lookahead': 'neg',
-                    'backref': 'backref_index',
-                    'match': None, 'accept': None,
-                    'dummy': None, 'unknown': None
-                    }
+        variants = {
+            'repeat': 'alt',
+            'alternative': 'alt',
+            'subexpr_begin': 'subexpr',
+            'subexpr_end': 'subexpr',
+            'line_begin_assertion': None,
+            'line_end_assertion': None,
+            'word_boundary': 'neg',
+            'subexpr_lookahead': 'neg',
+            'backref': 'backref_index',
+            'match': None,
+            'accept': None,
+            'dummy': None,
+            'unknown': None,
+        }
         v = variants[opcode]
 
         s = "opcode={}, next={}".format(opcode, next_id)
@@ -1963,8 +2049,9 @@ class StdAtomicPrinter(printer_base):
         self._value_type = self._val.type.template_argument(0)
         if self._value_type.tag is not None:
             typ = strip_versioned_namespace(self._value_type.tag)
-            if (typ.startswith('std::shared_ptr<')
-                    or typ.startswith('std::weak_ptr<')):
+            if typ.startswith('std::shared_ptr<') or typ.startswith(
+                'std::weak_ptr<'
+            ):
                 impl = val['_M_impl']
                 self._shptr_printer = SharedPointerPrinter(typename, impl)
                 self.children = self._shptr_children
@@ -1991,6 +2078,7 @@ class StdAtomicPrinter(printer_base):
 
 class StdFormatArgsPrinter(printer_base):
     """Print a std::basic_format_args."""
+
     # TODO: add printer for basic_format_arg<Context> and print out children.
     # TODO: add printer for __format::_ArgStore<Context, Args...>.
 
@@ -2068,8 +2156,10 @@ class StdChronoTimePointPrinter(printer_base):
     def _clock(self):
         clock = self._val.type.template_argument(0)
         name = strip_versioned_namespace(clock.name)
-        if name == 'std::chrono::_V2::system_clock' \
-                or name == 'std::chrono::system_clock':
+        if (
+            name == 'std::chrono::_V2::system_clock'
+            or name == 'std::chrono::system_clock'
+        ):
             return ('std::chrono::sys_time', 0)
         # XXX need to remove leap seconds from utc, gps, and tai
         if name == 'std::chrono::utc_clock':
@@ -2120,11 +2210,32 @@ class StdChronoZonedTimePrinter(printer_base):
         return 'std::chrono::zoned_time = {{ {} {} }}'.format(zone, time)
 
 
-months = [None, 'January', 'February', 'March', 'April', 'May', 'June',
-          'July', 'August', 'September', 'October', 'November', 'December']
-
-weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
-            'Saturday', 'Sunday']
+months = [
+    None,
+    'January',
+    'February',
+    'March',
+    'April',
+    'May',
+    'June',
+    'July',
+    'August',
+    'September',
+    'October',
+    'November',
+    'December',
+]
+
+weekdays = [
+    'Sunday',
+    'Monday',
+    'Tuesday',
+    'Wednesday',
+    'Thursday',
+    'Friday',
+    'Saturday',
+    'Sunday',
+]
 
 
 class StdChronoCalendarPrinter(printer_base):
@@ -2180,8 +2291,9 @@ class StdChronoCalendarPrinter(printer_base):
         if typ.startswith('std::chrono::hh_mm_ss'):
             fract = ''
             if val['fractional_width'] != 0:
-                fract = '.{:0{}d}'.format(int(val['_M_ss']['_M_r']),
-                                          int(val['fractional_width']))
+                fract = '.{:0{}d}'.format(
+                    int(val['_M_ss']['_M_r']), int(val['fractional_width'])
+                )
             h = int(val['_M_h']['__r'])
             m = int(val['_M_m']['__r'])
             s = int(val['_M_s']['__r'])
@@ -2239,8 +2351,15 @@ class StdChronoTimeZoneRulePrinter(printer_base):
         on = self._val['on']
         kind = on['kind']
         month = months[on['month']]
-        suffixes = {1: 'st', 2: 'nd', 3: 'rd',
-                    21: 'st', 22: 'nd', 23: 'rd', 31: 'st'}
+        suffixes = {
+            1: 'st',
+            2: 'nd',
+            3: 'rd',
+            21: 'st',
+            22: 'nd',
+            23: 'rd',
+            31: 'st',
+        }
         day = on['day_of_month']
         ordinal_day = '{}{}'.format(day, suffixes.get(day, 'th'))
         if kind == 0:  # DayOfMonth
@@ -2255,11 +2374,12 @@ class StdChronoTimeZoneRulePrinter(printer_base):
                 else:
                     direction = ('first', '>=')
                 day = on['day_of_month']
-                start = '{} {} {} {} {}'.format(direction[0], weekday,
-                                                direction[1], month,
-                                                ordinal_day)
+                start = '{} {} {} {} {}'.format(
+                    direction[0], weekday, direction[1], month, ordinal_day
+                )
         return 'time_zone rule {} from {} to {} starting on {}'.format(
-            self._val['name'], self._val['from'], self._val['to'], start)
+            self._val['name'], self._val['from'], self._val['to'], start
+        )
 
 
 class StdLocalePrinter(printer_base):
@@ -2292,7 +2412,7 @@ class StdLocalePrinter(printer_base):
             if len(uniq_names) == 1:
                 name = n
             elif len(uniq_names) == 2:
-                n1, n2 = (uniq_names)
+                n1, n2 = uniq_names
                 name_list = list(cat_names.values())
                 other = None
                 if name_list.count(n1) == 1:
@@ -2326,6 +2446,7 @@ class RxPrinter(object):
 
         return self._function(self.name, value)
 
+
 # A pretty-printer that conforms to the "PrettyPrinter" protocol from
 # gdb.printing.  It can also be used directly as an old-style printer.
 
@@ -2344,7 +2465,8 @@ class Printer(object):
         # FIXME
         if not self._compiled_rx.match(name):
             raise ValueError(
-                'libstdc++ programming error: "%s" does not match' % name)
+                'libstdc++ programming error: "%s" does not match' % name
+            )
         printer = RxPrinter(name, function)
         self._subprinters.append(printer)
         self._lookup[name] = printer
@@ -2353,8 +2475,9 @@ class Printer(object):
     def add_version(self, base, name, function):
         self.add(base + name, function)
         if '__cxx11' not in base:
-            vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' %
-                           _versioned_namespace, base)
+            vbase = re.sub(
+                '^(std|__gnu_cxx)::', r'\g<0>%s' % _versioned_namespace, base
+            )
             self.add(vbase + name, function)
 
     # Add a name using _GLIBCXX_BEGIN_NAMESPACE_CONTAINER.
@@ -2468,7 +2591,7 @@ class TemplateTypePrinter(object):
                     displayed_args.append(self._recognize_subtype(targ))
 
             # This assumes no class templates in the nested-name-specifier:
-            template_name = type_obj.tag[0:type_obj.tag.find('<')]
+            template_name = type_obj.tag[0 : type_obj.tag.find('<')]
             template_name = strip_inline_namespaces(template_name)
 
             return template_name + '<' + ', '.join(displayed_args) + '>'
@@ -2491,7 +2614,8 @@ class TemplateTypePrinter(object):
                     return self._recognize_subtype(type_obj.target()) + '&&'
 
             type_str = gdb.types.apply_type_recognizers(
-                gdb.types.get_type_recognizers(), type_obj)
+                gdb.types.get_type_recognizers(), type_obj
+            )
             if type_str:
                 return type_str
             return str(type_obj)
@@ -2528,8 +2652,9 @@ def add_one_template_type_printer(obj, name, defargs):
         # Add second type printer for same type in versioned namespace:
         ns = 'std::' + _versioned_namespace
         # PR 86112 Cannot use dict comprehension here:
-        defargs = dict((n, d.replace('std::', ns))
-                       for (n, d) in defargs.items())
+        defargs = dict(
+            (n, d.replace('std::', ns)) for (n, d) in defargs.items()
+        )
         printer = TemplateTypePrinter(ns + name, defargs)
         gdb.types.register_type_printer(obj, printer)
 
@@ -2595,7 +2720,8 @@ class FilteringTypePrinter(object):
 
                 try:
                     self._type_obj = gdb.lookup_type(
-                        self.name).strip_typedefs()
+                        self.name
+                    ).strip_typedefs()
                 except:
                     pass
 
@@ -2638,27 +2764,45 @@ def register_type_printers(obj):
         return
 
     # Add type printers for typedefs std::string, std::wstring etc.
-    for ch in (('', 'char'),
-               ('w', 'wchar_t'),
-               ('u8', 'char8_t'),
-               ('u16', 'char16_t'),
-               ('u32', 'char32_t')):
+    for ch in (
+        ('', 'char'),
+        ('w', 'wchar_t'),
+        ('u8', 'char8_t'),
+        ('u16', 'char16_t'),
+        ('u32', 'char32_t'),
+    ):
         add_one_type_printer(obj, 'basic_string', ch[0] + 'string', ch[1])
-        add_one_type_printer(obj, '__cxx11::basic_string',
-                             ch[0] + 'string', ch[1])
+        add_one_type_printer(
+            obj, '__cxx11::basic_string', ch[0] + 'string', ch[1]
+        )
         # Typedefs for __cxx11::basic_string used to be in namespace __cxx11:
-        add_one_type_printer(obj, '__cxx11::basic_string',
-                             '__cxx11::' + ch[0] + 'string', ch[1])
-        add_one_type_printer(obj, 'basic_string_view',
-                             ch[0] + 'string_view', ch[1])
+        add_one_type_printer(
+            obj, '__cxx11::basic_string', '__cxx11::' + ch[0] + 'string', ch[1]
+        )
+        add_one_type_printer(
+            obj, 'basic_string_view', ch[0] + 'string_view', ch[1]
+        )
 
     # Add type printers for typedefs std::istream, std::wistream etc.
     for ch in (('', 'char'), ('w', 'wchar_t')):
-        for x in ('ios', 'streambuf', 'istream', 'ostream', 'iostream',
-                  'filebuf', 'ifstream', 'ofstream', 'fstream'):
+        for x in (
+            'ios',
+            'streambuf',
+            'istream',
+            'ostream',
+            'iostream',
+            'filebuf',
+            'ifstream',
+            'ofstream',
+            'fstream',
+        ):
             add_one_type_printer(obj, 'basic_' + x, ch[0] + x, ch[1])
-        for x in ('stringbuf', 'istringstream', 'ostringstream',
-                  'stringstream'):
+        for x in (
+            'stringbuf',
+            'istringstream',
+            'ostringstream',
+            'stringstream',
+        ):
             add_one_type_printer(obj, 'basic_' + x, ch[0] + x, ch[1])
             # <sstream> types are in __cxx11 namespace, but typedefs aren't:
             add_one_type_printer(obj, '__cxx11::basic_' + x, ch[0] + x, ch[1])
@@ -2666,11 +2810,13 @@ def register_type_printers(obj):
     # Add type printers for typedefs regex, wregex, cmatch, wcmatch etc.
     for abi in ('', '__cxx11::'):
         for ch in (('', 'char'), ('w', 'wchar_t')):
-            add_one_type_printer(obj, abi + 'basic_regex',
-                                 abi + ch[0] + 'regex', ch[1])
+            add_one_type_printer(
+                obj, abi + 'basic_regex', abi + ch[0] + 'regex', ch[1]
+            )
         for ch in ('c', 's', 'wc', 'ws'):
             add_one_type_printer(
-                obj, abi + 'match_results', abi + ch + 'match')
+                obj, abi + 'match_results', abi + ch + 'match'
+            )
             for x in ('sub_match', 'regex_iterator', 'regex_token_iterator'):
                 add_one_type_printer(obj, abi + x, abi + ch + x)
 
@@ -2679,8 +2825,18 @@ def register_type_printers(obj):
     add_one_type_printer(obj, 'fpos', 'streampos')
 
     # Add type printers for <chrono> typedefs.
-    for dur in ('nanoseconds', 'microseconds', 'milliseconds', 'seconds',
-                'minutes', 'hours', 'days', 'weeks', 'years', 'months'):
+    for dur in (
+        'nanoseconds',
+        'microseconds',
+        'milliseconds',
+        'seconds',
+        'minutes',
+        'hours',
+        'days',
+        'weeks',
+        'years',
+        'months',
+    ):
         add_one_type_printer(obj, 'chrono::duration', 'chrono::' + dur)
 
     # Add type printers for <random> typedefs.
@@ -2696,50 +2852,82 @@ def register_type_printers(obj):
 
     # Add type printers for experimental::basic_string_view typedefs.
     ns = 'experimental::fundamentals_v1::'
-    for ch in (('', 'char'),
-               ('w', 'wchar_t'),
-               ('u8', 'char8_t'),
-               ('u16', 'char16_t'),
-               ('u32', 'char32_t')):
-        add_one_type_printer(obj, ns + 'basic_string_view',
-                             ns + ch[0] + 'string_view', ch[1])
+    for ch in (
+        ('', 'char'),
+        ('w', 'wchar_t'),
+        ('u8', 'char8_t'),
+        ('u16', 'char16_t'),
+        ('u32', 'char32_t'),
+    ):
+        add_one_type_printer(
+            obj, ns + 'basic_string_view', ns + ch[0] + 'string_view', ch[1]
+        )
 
     # Do not show defaulted template arguments in class templates.
-    add_one_template_type_printer(obj, 'unique_ptr',
-                                  {1: 'std::default_delete<{0}>'})
+    add_one_template_type_printer(
+        obj, 'unique_ptr', {1: 'std::default_delete<{0}>'}
+    )
     add_one_template_type_printer(obj, 'deque', {1: 'std::allocator<{0}>'})
     add_one_template_type_printer(
-        obj, 'forward_list', {1: 'std::allocator<{0}>'})
+        obj, 'forward_list', {1: 'std::allocator<{0}>'}
+    )
     add_one_template_type_printer(obj, 'list', {1: 'std::allocator<{0}>'})
     add_one_template_type_printer(
-        obj, '__cxx11::list', {1: 'std::allocator<{0}>'})
+        obj, '__cxx11::list', {1: 'std::allocator<{0}>'}
+    )
     add_one_template_type_printer(obj, 'vector', {1: 'std::allocator<{0}>'})
-    add_one_template_type_printer(obj, 'map',
-                                  {2: 'std::less<{0}>',
-                                   3: 'std::allocator<std::pair<{0} const, {1}>>'})
-    add_one_template_type_printer(obj, 'multimap',
-                                  {2: 'std::less<{0}>',
-                                   3: 'std::allocator<std::pair<{0} const, {1}>>'})
-    add_one_template_type_printer(obj, 'set',
-                                  {1: 'std::less<{0}>', 2: 'std::allocator<{0}>'})
-    add_one_template_type_printer(obj, 'multiset',
-                                  {1: 'std::less<{0}>', 2: 'std::allocator<{0}>'})
-    add_one_template_type_printer(obj, 'unordered_map',
-                                  {2: 'std::hash<{0}>',
-                                   3: 'std::equal_to<{0}>',
-                                   4: 'std::allocator<std::pair<{0} const, {1}>>'})
-    add_one_template_type_printer(obj, 'unordered_multimap',
-                                  {2: 'std::hash<{0}>',
-                                   3: 'std::equal_to<{0}>',
-                                   4: 'std::allocator<std::pair<{0} const, {1}>>'})
-    add_one_template_type_printer(obj, 'unordered_set',
-                                  {1: 'std::hash<{0}>',
-                                   2: 'std::equal_to<{0}>',
-                                   3: 'std::allocator<{0}>'})
-    add_one_template_type_printer(obj, 'unordered_multiset',
-                                  {1: 'std::hash<{0}>',
-                                   2: 'std::equal_to<{0}>',
-                                   3: 'std::allocator<{0}>'})
+    add_one_template_type_printer(
+        obj,
+        'map',
+        {2: 'std::less<{0}>', 3: 'std::allocator<std::pair<{0} const, {1}>>'},
+    )
+    add_one_template_type_printer(
+        obj,
+        'multimap',
+        {2: 'std::less<{0}>', 3: 'std::allocator<std::pair<{0} const, {1}>>'},
+    )
+    add_one_template_type_printer(
+        obj, 'set', {1: 'std::less<{0}>', 2: 'std::allocator<{0}>'}
+    )
+    add_one_template_type_printer(
+        obj, 'multiset', {1: 'std::less<{0}>', 2: 'std::allocator<{0}>'}
+    )
+    add_one_template_type_printer(
+        obj,
+        'unordered_map',
+        {
+            2: 'std::hash<{0}>',
+            3: 'std::equal_to<{0}>',
+            4: 'std::allocator<std::pair<{0} const, {1}>>',
+        },
+    )
+    add_one_template_type_printer(
+        obj,
+        'unordered_multimap',
+        {
+            2: 'std::hash<{0}>',
+            3: 'std::equal_to<{0}>',
+            4: 'std::allocator<std::pair<{0} const, {1}>>',
+        },
+    )
+    add_one_template_type_printer(
+        obj,
+        'unordered_set',
+        {
+            1: 'std::hash<{0}>',
+            2: 'std::equal_to<{0}>',
+            3: 'std::allocator<{0}>',
+        },
+    )
+    add_one_template_type_printer(
+        obj,
+        'unordered_multiset',
+        {
+            1: 'std::hash<{0}>',
+            2: 'std::equal_to<{0}>',
+            3: 'std::allocator<{0}>',
+        },
+    )
 
 
 def register_libstdcxx_printers(obj):
@@ -2768,7 +2956,8 @@ def build_libstdcxx_dictionary():
     # http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html
     libstdcxx_printer.add_version('std::', 'basic_string', StdStringPrinter)
     libstdcxx_printer.add_version(
-        'std::__cxx11::', 'basic_string', StdStringPrinter)
+        'std::__cxx11::', 'basic_string', StdStringPrinter
+    )
     libstdcxx_printer.add_container('std::', 'bitset', StdBitsetPrinter)
     libstdcxx_printer.add_container('std::', 'deque', StdDequePrinter)
     libstdcxx_printer.add_container('std::', 'list', StdListPrinter)
@@ -2777,8 +2966,9 @@ def build_libstdcxx_dictionary():
     libstdcxx_printer.add_container('std::', 'multimap', StdMapPrinter)
     libstdcxx_printer.add_container('std::', 'multiset', StdSetPrinter)
     libstdcxx_printer.add_version('std::', 'pair', StdPairPrinter)
-    libstdcxx_printer.add_version('std::', 'priority_queue',
-                                  StdStackOrQueuePrinter)
+    libstdcxx_printer.add_version(
+        'std::', 'priority_queue', StdStackOrQueuePrinter
+    )
     libstdcxx_printer.add_version('std::', 'queue', StdStackOrQueuePrinter)
     libstdcxx_printer.add_version('std::', 'tuple', StdTuplePrinter)
     libstdcxx_printer.add_container('std::', 'set', StdSetPrinter)
@@ -2789,10 +2979,12 @@ def build_libstdcxx_dictionary():
     libstdcxx_printer.add_version('std::', 'locale', StdLocalePrinter)
 
     if hasattr(gdb.Value, 'dynamic_type'):
-        libstdcxx_printer.add_version('std::', 'error_code',
-                                      StdErrorCodePrinter)
-        libstdcxx_printer.add_version('std::', 'error_condition',
-                                      StdErrorCodePrinter)
+        libstdcxx_printer.add_version(
+            'std::', 'error_code', StdErrorCodePrinter
+        )
+        libstdcxx_printer.add_version(
+            'std::', 'error_condition', StdErrorCodePrinter
+        )
 
     # Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.
     libstdcxx_printer.add('std::__debug::bitset', StdBitsetPrinter)
@@ -2808,119 +3000,173 @@ def build_libstdcxx_dictionary():
     # For array - the default GDB pretty-printer seems reasonable.
     libstdcxx_printer.add_version('std::', 'shared_ptr', SharedPointerPrinter)
     libstdcxx_printer.add_version('std::', 'weak_ptr', SharedPointerPrinter)
-    libstdcxx_printer.add_container('std::', 'unordered_map',
-                                    Tr1UnorderedMapPrinter)
-    libstdcxx_printer.add_container('std::', 'unordered_set',
-                                    Tr1UnorderedSetPrinter)
-    libstdcxx_printer.add_container('std::', 'unordered_multimap',
-                                    Tr1UnorderedMapPrinter)
-    libstdcxx_printer.add_container('std::', 'unordered_multiset',
-                                    Tr1UnorderedSetPrinter)
-    libstdcxx_printer.add_container('std::', 'forward_list',
-                                    StdForwardListPrinter)
+    libstdcxx_printer.add_container(
+        'std::', 'unordered_map', Tr1UnorderedMapPrinter
+    )
+    libstdcxx_printer.add_container(
+        'std::', 'unordered_set', Tr1UnorderedSetPrinter
+    )
+    libstdcxx_printer.add_container(
+        'std::', 'unordered_multimap', Tr1UnorderedMapPrinter
+    )
+    libstdcxx_printer.add_container(
+        'std::', 'unordered_multiset', Tr1UnorderedSetPrinter
+    )
+    libstdcxx_printer.add_container(
+        'std::', 'forward_list', StdForwardListPrinter
+    )
 
     libstdcxx_printer.add_version(
-        'std::tr1::', 'shared_ptr', SharedPointerPrinter)
+        'std::tr1::', 'shared_ptr', SharedPointerPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::tr1::', 'weak_ptr', SharedPointerPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::tr1::', 'unordered_map', Tr1UnorderedMapPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::tr1::', 'unordered_set', Tr1UnorderedSetPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::tr1::', 'unordered_multimap', Tr1UnorderedMapPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::tr1::', 'unordered_multiset', Tr1UnorderedSetPrinter
+    )
+
     libstdcxx_printer.add_version(
-        'std::tr1::', 'weak_ptr', SharedPointerPrinter)
-    libstdcxx_printer.add_version('std::tr1::', 'unordered_map',
-                                  Tr1UnorderedMapPrinter)
-    libstdcxx_printer.add_version('std::tr1::', 'unordered_set',
-                                  Tr1UnorderedSetPrinter)
-    libstdcxx_printer.add_version('std::tr1::', 'unordered_multimap',
-                                  Tr1UnorderedMapPrinter)
-    libstdcxx_printer.add_version('std::tr1::', 'unordered_multiset',
-                                  Tr1UnorderedSetPrinter)
-
-    libstdcxx_printer.add_version('std::', 'initializer_list',
-                                  StdInitializerListPrinter)
+        'std::', 'initializer_list', StdInitializerListPrinter
+    )
     libstdcxx_printer.add_version('std::', 'atomic', StdAtomicPrinter)
     libstdcxx_printer.add_version(
-        'std::', 'basic_stringbuf', StdStringBufPrinter)
+        'std::', 'basic_stringbuf', StdStringBufPrinter
+    )
     libstdcxx_printer.add_version(
-        'std::__cxx11::', 'basic_stringbuf', StdStringBufPrinter)
+        'std::__cxx11::', 'basic_stringbuf', StdStringBufPrinter
+    )
     for sstream in ('istringstream', 'ostringstream', 'stringstream'):
         libstdcxx_printer.add_version(
-            'std::', 'basic_' + sstream, StdStringStreamPrinter)
+            'std::', 'basic_' + sstream, StdStringStreamPrinter
+        )
         libstdcxx_printer.add_version(
-            'std::__cxx11::', 'basic_' + sstream, StdStringStreamPrinter)
+            'std::__cxx11::', 'basic_' + sstream, StdStringStreamPrinter
+        )
 
-    libstdcxx_printer.add_version('std::chrono::', 'duration',
-                                  StdChronoDurationPrinter)
-    libstdcxx_printer.add_version('std::chrono::', 'time_point',
-                                  StdChronoTimePointPrinter)
+    libstdcxx_printer.add_version(
+        'std::chrono::', 'duration', StdChronoDurationPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::chrono::', 'time_point', StdChronoTimePointPrinter
+    )
 
     # std::regex components
-    libstdcxx_printer.add_version('std::__detail::', '_State',
-                                  StdRegexStatePrinter)
+    libstdcxx_printer.add_version(
+        'std::__detail::', '_State', StdRegexStatePrinter
+    )
 
     # These are the C++11 printer registrations for -D_GLIBCXX_DEBUG cases.
     # The tr1 namespace containers do not have any debug equivalents,
     # so do not register printers for them.
-    libstdcxx_printer.add('std::__debug::unordered_map',
-                          Tr1UnorderedMapPrinter)
-    libstdcxx_printer.add('std::__debug::unordered_set',
-                          Tr1UnorderedSetPrinter)
-    libstdcxx_printer.add('std::__debug::unordered_multimap',
-                          Tr1UnorderedMapPrinter)
-    libstdcxx_printer.add('std::__debug::unordered_multiset',
-                          Tr1UnorderedSetPrinter)
-    libstdcxx_printer.add('std::__debug::forward_list',
-                          StdForwardListPrinter)
+    libstdcxx_printer.add(
+        'std::__debug::unordered_map', Tr1UnorderedMapPrinter
+    )
+    libstdcxx_printer.add(
+        'std::__debug::unordered_set', Tr1UnorderedSetPrinter
+    )
+    libstdcxx_printer.add(
+        'std::__debug::unordered_multimap', Tr1UnorderedMapPrinter
+    )
+    libstdcxx_printer.add(
+        'std::__debug::unordered_multiset', Tr1UnorderedSetPrinter
+    )
+    libstdcxx_printer.add('std::__debug::forward_list', StdForwardListPrinter)
 
     # Library Fundamentals TS components
-    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
-                                  'any', StdExpAnyPrinter)
-    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
-                                  'optional', StdExpOptionalPrinter)
-    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
-                                  'basic_string_view', StdExpStringViewPrinter)
+    libstdcxx_printer.add_version(
+        'std::experimental::fundamentals_v1::', 'any', StdExpAnyPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::experimental::fundamentals_v1::',
+        'optional',
+        StdExpOptionalPrinter,
+    )
+    libstdcxx_printer.add_version(
+        'std::experimental::fundamentals_v1::',
+        'basic_string_view',
+        StdExpStringViewPrinter,
+    )
     # Filesystem TS components
-    libstdcxx_printer.add_version('std::experimental::filesystem::v1::',
-                                  'path', StdExpPathPrinter)
-    libstdcxx_printer.add_version('std::experimental::filesystem::v1::__cxx11::',
-                                  'path', StdExpPathPrinter)
-    libstdcxx_printer.add_version('std::filesystem::',
-                                  'path', StdPathPrinter)
-    libstdcxx_printer.add_version('std::filesystem::__cxx11::',
-                                  'path', StdPathPrinter)
+    libstdcxx_printer.add_version(
+        'std::experimental::filesystem::v1::', 'path', StdExpPathPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::experimental::filesystem::v1::__cxx11::',
+        'path',
+        StdExpPathPrinter,
+    )
+    libstdcxx_printer.add_version('std::filesystem::', 'path', StdPathPrinter)
+    libstdcxx_printer.add_version(
+        'std::filesystem::__cxx11::', 'path', StdPathPrinter
+    )
 
     # C++17 components
-    libstdcxx_printer.add_version('std::',
-                                  'any', StdExpAnyPrinter)
-    libstdcxx_printer.add_version('std::',
-                                  'optional', StdExpOptionalPrinter)
-    libstdcxx_printer.add_version('std::',
-                                  'basic_string_view', StdExpStringViewPrinter)
-    libstdcxx_printer.add_version('std::',
-                                  'variant', StdVariantPrinter)
-    libstdcxx_printer.add_version('std::',
-                                  '_Node_handle', StdNodeHandlePrinter)
+    libstdcxx_printer.add_version('std::', 'any', StdExpAnyPrinter)
+    libstdcxx_printer.add_version('std::', 'optional', StdExpOptionalPrinter)
+    libstdcxx_printer.add_version(
+        'std::', 'basic_string_view', StdExpStringViewPrinter
+    )
+    libstdcxx_printer.add_version('std::', 'variant', StdVariantPrinter)
+    libstdcxx_printer.add_version(
+        'std::', '_Node_handle', StdNodeHandlePrinter
+    )
 
     # C++20 components
     libstdcxx_printer.add_version(
-        'std::', 'partial_ordering', StdCmpCatPrinter)
+        'std::', 'partial_ordering', StdCmpCatPrinter
+    )
     libstdcxx_printer.add_version('std::', 'weak_ordering', StdCmpCatPrinter)
     libstdcxx_printer.add_version('std::', 'strong_ordering', StdCmpCatPrinter)
     libstdcxx_printer.add_version('std::', 'span', StdSpanPrinter)
-    libstdcxx_printer.add_version('std::', 'basic_format_args',
-                                  StdFormatArgsPrinter)
-    for c in ['day', 'month', 'year', 'weekday', 'weekday_indexed', 'weekday_last',
-              'month_day', 'month_day_last', 'month_weekday', 'month_weekday_last',
-              'year_month', 'year_month_day', 'year_month_day_last',
-              'year_month_weekday', 'year_month_weekday_last', 'hh_mm_ss']:
-        libstdcxx_printer.add_version('std::chrono::', c,
-                                      StdChronoCalendarPrinter)
-    libstdcxx_printer.add_version('std::chrono::', 'time_zone',
-                                  StdChronoTimeZonePrinter)
-    libstdcxx_printer.add_version('std::chrono::', 'time_zone_link',
-                                  StdChronoTimeZonePrinter)
-    libstdcxx_printer.add_version('std::chrono::', 'zoned_time',
-                                  StdChronoZonedTimePrinter)
-    libstdcxx_printer.add_version('std::chrono::', 'leap_second',
-                                  StdChronoLeapSecondPrinter)
     libstdcxx_printer.add_version(
-        'std::chrono::', 'tzdb', StdChronoTzdbPrinter)
+        'std::', 'basic_format_args', StdFormatArgsPrinter
+    )
+    for c in [
+        'day',
+        'month',
+        'year',
+        'weekday',
+        'weekday_indexed',
+        'weekday_last',
+        'month_day',
+        'month_day_last',
+        'month_weekday',
+        'month_weekday_last',
+        'year_month',
+        'year_month_day',
+        'year_month_day_last',
+        'year_month_weekday',
+        'year_month_weekday_last',
+        'hh_mm_ss',
+    ]:
+        libstdcxx_printer.add_version(
+            'std::chrono::', c, StdChronoCalendarPrinter
+        )
+    libstdcxx_printer.add_version(
+        'std::chrono::', 'time_zone', StdChronoTimeZonePrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::chrono::', 'time_zone_link', StdChronoTimeZonePrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::chrono::', 'zoned_time', StdChronoZonedTimePrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::chrono::', 'leap_second', StdChronoLeapSecondPrinter
+    )
+    libstdcxx_printer.add_version(
+        'std::chrono::', 'tzdb', StdChronoTzdbPrinter
+    )
     # libstdcxx_printer.add_version('std::chrono::(anonymous namespace)', 'Rule',
     #                              StdChronoTimeZoneRulePrinter)
 
@@ -2930,37 +3176,51 @@ def build_libstdcxx_dictionary():
     if True:
         # These shouldn't be necessary, if GDB "print *i" worked.
         # But it often doesn't, so here they are.
-        libstdcxx_printer.add_container('std::', '_List_iterator',
-                                        StdListIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_List_const_iterator',
-                                        StdListIteratorPrinter)
-        libstdcxx_printer.add_version('std::', '_Rb_tree_iterator',
-                                      StdRbtreeIteratorPrinter)
-        libstdcxx_printer.add_version('std::', '_Rb_tree_const_iterator',
-                                      StdRbtreeIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_Deque_iterator',
-                                        StdDequeIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_Deque_const_iterator',
-                                        StdDequeIteratorPrinter)
-        libstdcxx_printer.add_version('__gnu_cxx::', '__normal_iterator',
-                                      StdVectorIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_Bit_iterator',
-                                        StdBitIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_Bit_const_iterator',
-                                        StdBitIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_Bit_reference',
-                                        StdBitReferencePrinter)
-        libstdcxx_printer.add_version('__gnu_cxx::', '_Slist_iterator',
-                                      StdSlistIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_Fwd_list_iterator',
-                                        StdFwdListIteratorPrinter)
-        libstdcxx_printer.add_container('std::', '_Fwd_list_const_iterator',
-                                        StdFwdListIteratorPrinter)
+        libstdcxx_printer.add_container(
+            'std::', '_List_iterator', StdListIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_List_const_iterator', StdListIteratorPrinter
+        )
+        libstdcxx_printer.add_version(
+            'std::', '_Rb_tree_iterator', StdRbtreeIteratorPrinter
+        )
+        libstdcxx_printer.add_version(
+            'std::', '_Rb_tree_const_iterator', StdRbtreeIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_Deque_iterator', StdDequeIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_Deque_const_iterator', StdDequeIteratorPrinter
+        )
+        libstdcxx_printer.add_version(
+            '__gnu_cxx::', '__normal_iterator', StdVectorIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_Bit_iterator', StdBitIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_Bit_const_iterator', StdBitIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_Bit_reference', StdBitReferencePrinter
+        )
+        libstdcxx_printer.add_version(
+            '__gnu_cxx::', '_Slist_iterator', StdSlistIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_Fwd_list_iterator', StdFwdListIteratorPrinter
+        )
+        libstdcxx_printer.add_container(
+            'std::', '_Fwd_list_const_iterator', StdFwdListIteratorPrinter
+        )
 
         # Debug (compiled with -D_GLIBCXX_DEBUG) printer
         # registrations.
-        libstdcxx_printer.add('__gnu_debug::_Safe_iterator',
-                              StdDebugIteratorPrinter)
+        libstdcxx_printer.add(
+            '__gnu_debug::_Safe_iterator', StdDebugIteratorPrinter
+        )
 
 
 build_libstdcxx_dictionary()
diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
index 42e60eb57b1..b9b32927e56 100644
--- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py
+++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
@@ -15,9 +15,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import re
+
 import gdb
 import gdb.xmethod
-import re
 
 matcher_name_prefix = 'libstdc++::'
 
@@ -25,11 +26,14 @@ matcher_name_prefix = 'libstdc++::'
 def get_bool_type():
     return gdb.lookup_type('bool')
 
+
 def get_std_size_type():
     return gdb.lookup_type('std::size_t')
 
+
 _versioned_namespace = '__8::'
 
+
 def is_specialization_of(x, template_name):
     """
     Test whether a type is a specialization of the named class template.
@@ -42,11 +46,13 @@ def is_specialization_of(x, template_name):
     template_name = '(%s)?%s' % (_versioned_namespace, template_name)
     return re.match(r'^std::(__\d::)?%s<.*>$' % template_name, x) is not None
 
+
 class LibStdCxxXMethod(gdb.xmethod.XMethod):
     def __init__(self, name, worker_class):
         gdb.xmethod.XMethod.__init__(self, name)
         self.worker_class = worker_class
 
+
 # Xmethods for std::array
 
 
@@ -85,7 +91,7 @@ class ArrayEmptyWorker(ArrayWorkerBase):
         return get_bool_type()
 
     def __call__(self, obj):
-        return (int(self._size) == 0)
+        return int(self._size) == 0
 
 
 class ArrayFrontWorker(ArrayWorkerBase):
@@ -134,8 +140,10 @@ class ArrayAtWorker(ArrayWorkerBase):
 
     def __call__(self, obj, index):
         if int(index) >= int(self._size):
-            raise IndexError('Array index "%d" should not be >= %d.' %
-                             ((int(index), self._size)))
+            raise IndexError(
+                'Array index "%d" should not be >= %d.'
+                % ((int(index), self._size))
+            )
         return obj['_M_elems'][index]
 
 
@@ -158,8 +166,9 @@ class ArraySubscriptWorker(ArrayWorkerBase):
 
 class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher):
     def __init__(self):
-        gdb.xmethod.XMethodMatcher.__init__(self,
-                                            matcher_name_prefix + 'array')
+        gdb.xmethod.XMethodMatcher.__init__(
+            self, matcher_name_prefix + 'array'
+        )
         self._method_dict = {
             'size': LibStdCxxXMethod('size', ArraySizeWorker),
             'empty': LibStdCxxXMethod('empty', ArrayEmptyWorker),
@@ -213,8 +222,10 @@ class DequeEmptyWorker(DequeWorkerBase):
         return get_bool_type()
 
     def __call__(self, obj):
-        return (obj['_M_impl']['_M_start']['_M_cur'] ==
-                obj['_M_impl']['_M_finish']['_M_cur'])
+        return (
+            obj['_M_impl']['_M_start']['_M_cur']
+            == obj['_M_impl']['_M_finish']['_M_cur']
+        )
 
 
 class DequeSizeWorker(DequeWorkerBase):
@@ -247,8 +258,10 @@ class DequeBackWorker(DequeWorkerBase):
         return self._val_type
 
     def __call__(self, obj):
-        if (obj['_M_impl']['_M_finish']['_M_cur'] ==
-                obj['_M_impl']['_M_finish']['_M_first']):
+        if (
+            obj['_M_impl']['_M_finish']['_M_cur']
+            == obj['_M_impl']['_M_finish']['_M_first']
+        ):
             prev_node = obj['_M_impl']['_M_finish']['_M_node'] - 1
             return prev_node[0][self._bufsize - 1]
         else:
@@ -276,23 +289,26 @@ class DequeAtWorker(DequeWorkerBase):
     def __call__(self, obj, index):
         deque_size = int(self.size(obj))
         if int(index) >= deque_size:
-            raise IndexError('Deque index "%d" should not be >= %d.' %
-                             (int(index), deque_size))
+            raise IndexError(
+                'Deque index "%d" should not be >= %d.'
+                % (int(index), deque_size)
+            )
         else:
             return self.index(obj, index)
 
 
 class DequeMethodsMatcher(gdb.xmethod.XMethodMatcher):
     def __init__(self):
-        gdb.xmethod.XMethodMatcher.__init__(self,
-                                            matcher_name_prefix + 'deque')
+        gdb.xmethod.XMethodMatcher.__init__(
+            self, matcher_name_prefix + 'deque'
+        )
         self._method_dict = {
             'empty': LibStdCxxXMethod('empty', DequeEmptyWorker),
             'size': LibStdCxxXMethod('size', DequeSizeWorker),
             'front': LibStdCxxXMethod('front', DequeFrontWorker),
             'back': LibStdCxxXMethod('back', DequeBackWorker),
             'operator[]': LibStdCxxXMethod('operator[]', DequeSubscriptWorker),
-            'at': LibStdCxxXMethod('at', DequeAtWorker)
+            'at': LibStdCxxXMethod('at', DequeAtWorker),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
 
@@ -304,6 +320,7 @@ class DequeMethodsMatcher(gdb.xmethod.XMethodMatcher):
             return None
         return method.worker_class(class_type.template_argument(0))
 
+
 # Xmethods for std::forward_list
 
 
@@ -340,7 +357,7 @@ class ForwardListMethodsMatcher(gdb.xmethod.XMethodMatcher):
         gdb.xmethod.XMethodMatcher.__init__(self, matcher_name)
         self._method_dict = {
             'empty': LibStdCxxXMethod('empty', ForwardListEmptyWorker),
-            'front': LibStdCxxXMethod('front', ForwardListFrontWorker)
+            'front': LibStdCxxXMethod('front', ForwardListFrontWorker),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
 
@@ -354,6 +371,7 @@ class ForwardListMethodsMatcher(gdb.xmethod.XMethodMatcher):
         node_type = gdb.lookup_type(str(class_type) + '::_Node').pointer()
         return method.worker_class(val_type, node_type)
 
+
 # Xmethods for std::list
 
 
@@ -421,13 +439,12 @@ class ListBackWorker(ListWorkerBase):
 
 class ListMethodsMatcher(gdb.xmethod.XMethodMatcher):
     def __init__(self):
-        gdb.xmethod.XMethodMatcher.__init__(self,
-                                            matcher_name_prefix + 'list')
+        gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'list')
         self._method_dict = {
             'empty': LibStdCxxXMethod('empty', ListEmptyWorker),
             'size': LibStdCxxXMethod('size', ListSizeWorker),
             'front': LibStdCxxXMethod('front', ListFrontWorker),
-            'back': LibStdCxxXMethod('back', ListBackWorker)
+            'back': LibStdCxxXMethod('back', ListBackWorker),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
 
@@ -441,6 +458,7 @@ class ListMethodsMatcher(gdb.xmethod.XMethodMatcher):
         node_type = gdb.lookup_type(str(class_type) + '::_Node').pointer()
         return method.worker_class(val_type, node_type)
 
+
 # Xmethods for std::vector
 
 
@@ -523,8 +541,9 @@ class VectorAtWorker(VectorWorkerBase):
     def __call__(self, obj, index):
         size = int(self.size(obj))
         if int(index) >= size:
-            raise IndexError('Vector index "%d" should not be >= %d.' %
-                             ((int(index), size)))
+            raise IndexError(
+                'Vector index "%d" should not be >= %d.' % ((int(index), size))
+            )
         return self.get(obj, int(index))
 
 
@@ -541,16 +560,18 @@ class VectorSubscriptWorker(VectorWorkerBase):
 
 class VectorMethodsMatcher(gdb.xmethod.XMethodMatcher):
     def __init__(self):
-        gdb.xmethod.XMethodMatcher.__init__(self,
-                                            matcher_name_prefix + 'vector')
+        gdb.xmethod.XMethodMatcher.__init__(
+            self, matcher_name_prefix + 'vector'
+        )
         self._method_dict = {
             'size': LibStdCxxXMethod('size', VectorSizeWorker),
             'empty': LibStdCxxXMethod('empty', VectorEmptyWorker),
             'front': LibStdCxxXMethod('front', VectorFrontWorker),
             'back': LibStdCxxXMethod('back', VectorBackWorker),
             'at': LibStdCxxXMethod('at', VectorAtWorker),
-            'operator[]': LibStdCxxXMethod('operator[]',
-                                           VectorSubscriptWorker),
+            'operator[]': LibStdCxxXMethod(
+                'operator[]', VectorSubscriptWorker
+            ),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
 
@@ -562,6 +583,7 @@ class VectorMethodsMatcher(gdb.xmethod.XMethodMatcher):
             return None
         return method.worker_class(class_type.template_argument(0))
 
+
 # Xmethods for associative containers
 
 
@@ -597,13 +619,13 @@ class AssociativeContainerSizeWorker(AssociativeContainerWorkerBase):
 
 class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher):
     def __init__(self, name):
-        gdb.xmethod.XMethodMatcher.__init__(self,
-                                            matcher_name_prefix + name)
+        gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + name)
         self._name = name
         self._method_dict = {
             'size': LibStdCxxXMethod('size', AssociativeContainerSizeWorker),
-            'empty': LibStdCxxXMethod('empty',
-                                      AssociativeContainerEmptyWorker),
+            'empty': LibStdCxxXMethod(
+                'empty', AssociativeContainerEmptyWorker
+            ),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
 
@@ -616,6 +638,7 @@ class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher):
         unordered = 'unordered' in self._name
         return method.worker_class(unordered)
 
+
 # Xmethods for std::unique_ptr
 
 
@@ -651,7 +674,7 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker):
         else:
             return None
         tuple_impl_type = tuple_member.type.fields()[0].type  # _Tuple_impl
-        tuple_head_type = tuple_impl_type.fields()[1].type   # _Head_base
+        tuple_head_type = tuple_impl_type.fields()[1].type  # _Head_base
         head_field = tuple_head_type.fields()[0]
         if head_field.name == '_M_head_impl':
             return tuple_member.cast(tuple_head_type)['_M_head_impl']
@@ -700,13 +723,16 @@ class UniquePtrSubscriptWorker(UniquePtrGetWorker):
 
 class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher):
     def __init__(self):
-        gdb.xmethod.XMethodMatcher.__init__(self,
-                                            matcher_name_prefix + 'unique_ptr')
+        gdb.xmethod.XMethodMatcher.__init__(
+            self, matcher_name_prefix + 'unique_ptr'
+        )
         self._method_dict = {
             'get': LibStdCxxXMethod('get', UniquePtrGetWorker),
             'operator->': LibStdCxxXMethod('operator->', UniquePtrGetWorker),
             'operator*': LibStdCxxXMethod('operator*', UniquePtrDerefWorker),
-            'operator[]': LibStdCxxXMethod('operator[]', UniquePtrSubscriptWorker),
+            'operator[]': LibStdCxxXMethod(
+                'operator[]', UniquePtrSubscriptWorker
+            ),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
 
@@ -721,6 +747,7 @@ class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher):
             return worker
         return None
 
+
 # Xmethods for std::shared_ptr
 
 
@@ -787,8 +814,10 @@ class SharedPtrSubscriptWorker(SharedPtrGetWorker):
         # Check bounds if _elem_type is an array of known bound
         m = re.match(r'.*\[(\d+)]$', str(self._elem_type))
         if m and index >= int(m.group(1)):
-            raise IndexError('shared_ptr<%s> index "%d" should not be >= %d.' %
-                             (self._elem_type, int(index), int(m.group(1))))
+            raise IndexError(
+                'shared_ptr<%s> index "%d" should not be >= %d.'
+                % (self._elem_type, int(index), int(m.group(1)))
+            )
         return SharedPtrGetWorker.__call__(self, obj)[index]
 
 
@@ -827,14 +856,19 @@ class SharedPtrUniqueWorker(SharedPtrUseCountWorker):
 
 class SharedPtrMethodsMatcher(gdb.xmethod.XMethodMatcher):
     def __init__(self):
-        gdb.xmethod.XMethodMatcher.__init__(self,
-                                            matcher_name_prefix + 'shared_ptr')
+        gdb.xmethod.XMethodMatcher.__init__(
+            self, matcher_name_prefix + 'shared_ptr'
+        )
         self._method_dict = {
             'get': LibStdCxxXMethod('get', SharedPtrGetWorker),
             'operator->': LibStdCxxXMethod('operator->', SharedPtrGetWorker),
             'operator*': LibStdCxxXMethod('operator*', SharedPtrDerefWorker),
-            'operator[]': LibStdCxxXMethod('operator[]', SharedPtrSubscriptWorker),
-            'use_count': LibStdCxxXMethod('use_count', SharedPtrUseCountWorker),
+            'operator[]': LibStdCxxXMethod(
+                'operator[]', SharedPtrSubscriptWorker
+            ),
+            'use_count': LibStdCxxXMethod(
+                'use_count', SharedPtrUseCountWorker
+            ),
             'unique': LibStdCxxXMethod('unique', SharedPtrUniqueWorker),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
@@ -849,7 +883,7 @@ class SharedPtrMethodsMatcher(gdb.xmethod.XMethodMatcher):
         if worker._supports(method_name):
             return worker
         return None
-\f
+
 
 def register_libstdcxx_xmethods(locus):
     gdb.xmethod.register_xmethod_matcher(locus, ArrayMethodsMatcher())
@@ -858,20 +892,28 @@ def register_libstdcxx_xmethods(locus):
     gdb.xmethod.register_xmethod_matcher(locus, ListMethodsMatcher())
     gdb.xmethod.register_xmethod_matcher(locus, VectorMethodsMatcher())
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('set'))
+        locus, AssociativeContainerMethodsMatcher('set')
+    )
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('map'))
+        locus, AssociativeContainerMethodsMatcher('map')
+    )
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('multiset'))
+        locus, AssociativeContainerMethodsMatcher('multiset')
+    )
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('multimap'))
+        locus, AssociativeContainerMethodsMatcher('multimap')
+    )
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('unordered_set'))
+        locus, AssociativeContainerMethodsMatcher('unordered_set')
+    )
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('unordered_map'))
+        locus, AssociativeContainerMethodsMatcher('unordered_map')
+    )
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('unordered_multiset'))
+        locus, AssociativeContainerMethodsMatcher('unordered_multiset')
+    )
     gdb.xmethod.register_xmethod_matcher(
-        locus, AssociativeContainerMethodsMatcher('unordered_multimap'))
+        locus, AssociativeContainerMethodsMatcher('unordered_multimap')
+    )
     gdb.xmethod.register_xmethod_matcher(locus, UniquePtrMethodsMatcher())
     gdb.xmethod.register_xmethod_matcher(locus, SharedPtrMethodsMatcher())
diff --git a/libstdc++-v3/python/pyproject.toml b/libstdc++-v3/python/pyproject.toml
new file mode 100644
index 00000000000..dd4c4bf5df1
--- /dev/null
+++ b/libstdc++-v3/python/pyproject.toml
@@ -0,0 +1,6 @@
+[tool.black]
+line-length = 79
+skip-string-normalization = true
+
+[tool.isort]
+profile = "black"
-- 
2.40.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC 2/2] libstdc++: Add flake8 configuration
  2023-10-04 16:58 [RFC 0/2] black, isort, and flake8 configuration Tom Tromey
  2023-10-04 16:58 ` [RFC 1/2] libstdc++: Use 'black' and 'isort' in pretty printers Tom Tromey
@ 2023-10-04 16:58 ` Tom Tromey
  2024-04-04 13:32 ` [RFC 0/2] black, isort, and " Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2023-10-04 16:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Tom Tromey

flake8 is a Python linter.  This patch adds a .flake8 configuration
file (flake8 does not use pyproject.toml for some reason) and fixes a
few trivial flake8 warnings.

After this patch, the only remaining flake8 warnings are about unused
imports (there are two - but they are not completely trivial to
remove) and the use of bare "except:".

It is possible to change the flake8 configuration to suppress these
warnings, but I haven't done so here.

libstdc++-v3/ChangeLog:

	* python/.flake8: New file.
	* python/libstdcxx/v6/__init__.py: Remove blank line.
	* python/libstdcxx/v6/printers.py: Reformat two comments.
---
 libstdc++-v3/python/.flake8                  | 3 +++
 libstdc++-v3/python/libstdcxx/__init__.py    | 1 -
 libstdc++-v3/python/libstdcxx/v6/printers.py | 8 ++++----
 3 files changed, 7 insertions(+), 5 deletions(-)
 create mode 100644 libstdc++-v3/python/.flake8

diff --git a/libstdc++-v3/python/.flake8 b/libstdc++-v3/python/.flake8
new file mode 100644
index 00000000000..7ffe4d6e0f7
--- /dev/null
+++ b/libstdc++-v3/python/.flake8
@@ -0,0 +1,3 @@
+[flake8]
+max-line-length = 79
+extend-ignore = E203
diff --git a/libstdc++-v3/python/libstdcxx/__init__.py b/libstdc++-v3/python/libstdcxx/__init__.py
index 8b137891791..e69de29bb2d 100644
--- a/libstdc++-v3/python/libstdcxx/__init__.py
+++ b/libstdc++-v3/python/libstdcxx/__init__.py
@@ -1 +0,0 @@
-
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index e26b8b36013..202fa450a91 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -2672,8 +2672,8 @@ class FilteringTypePrinter(object):
         name (str): The typedef-name that will be used instead.
         targ1 (str, optional): The first template argument. Defaults to None.
 
-    Checks if a specialization of the class template 'template' is the same type
-    as the typedef 'name', and prints it as 'name' instead.
+    Checks if a specialization of the class template 'template' is the same
+    type as the typedef 'name', and prints it as 'name' instead.
 
     e.g. if an instantiation of std::basic_istream<C, T> is the same type as
     std::istream then print it as std::istream.
@@ -3167,8 +3167,8 @@ def build_libstdcxx_dictionary():
     libstdcxx_printer.add_version(
         'std::chrono::', 'tzdb', StdChronoTzdbPrinter
     )
-    # libstdcxx_printer.add_version('std::chrono::(anonymous namespace)', 'Rule',
-    #                              StdChronoTimeZoneRulePrinter)
+    # libstdcxx_printer.add_version('std::chrono::(anonymous namespace)',
+    #                               'Rule', StdChronoTimeZoneRulePrinter)
 
     # Extensions.
     libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter)
-- 
2.40.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC 0/2] black, isort, and flake8 configuration
  2023-10-04 16:58 [RFC 0/2] black, isort, and flake8 configuration Tom Tromey
  2023-10-04 16:58 ` [RFC 1/2] libstdc++: Use 'black' and 'isort' in pretty printers Tom Tromey
  2023-10-04 16:58 ` [RFC 2/2] libstdc++: Add flake8 configuration Tom Tromey
@ 2024-04-04 13:32 ` Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2024-04-04 13:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gcc-patches, libstdc++

>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> This short series adds configuration files for black ("opinionated"
Tom> code formatter), isort (import sorter) and flake8 (Python lint) to
Tom> libstdc++.

Tom> I marked it as RFC since sometimes people don't like black's output.
Tom> In gdb we use it -- at first I found some of its decisions a little
Tom> odd, but overall it's nice not to have to review for or worry about
Tom> the minitia of code formatting.

FWIW in gdb we recently updated our .pre-commit-config.yaml to
automatically run all three of these tools.  What this means is that
it's now very easy for developers to ensure that the Python code in the
tree remains clean -- is correctly formatted, passes flake8 checking, etc.

The tool is opt-in but also extremely easy to use.

Anyway, if you're at all interested, I could refresh this series to
enable flake8 cleanliness and then add a .pre-commit-config.yaml as well.

thanks,
Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-04 13:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-04 16:58 [RFC 0/2] black, isort, and flake8 configuration Tom Tromey
2023-10-04 16:58 ` [RFC 1/2] libstdc++: Use 'black' and 'isort' in pretty printers Tom Tromey
2023-10-04 16:58 ` [RFC 2/2] libstdc++: Add flake8 configuration Tom Tromey
2024-04-04 13:32 ` [RFC 0/2] black, isort, and " Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).