formatter: ditch namedtuple in favor of attr
authorYuya Nishihara <yuya@tcha.org>
Thu, 03 May 2018 15:08:16 +0900
changeset 37887 395571419274
parent 37886 3fe1c9263024
child 37888 853001c84114
formatter: ditch namedtuple in favor of attr
mercurial/formatter.py
--- a/mercurial/formatter.py	Sun Apr 29 15:52:01 2018 +0900
+++ b/mercurial/formatter.py	Thu May 03 15:08:16 2018 +0900
@@ -107,7 +107,6 @@
 
 from __future__ import absolute_import, print_function
 
-import collections
 import contextlib
 import itertools
 import os
@@ -117,6 +116,9 @@
     hex,
     short,
 )
+from .thirdparty import (
+    attr,
+)
 
 from . import (
     error,
@@ -413,8 +415,11 @@
         baseformatter.end(self)
         self._renderitem('docfooter', {})
 
-templatespec = collections.namedtuple(r'templatespec',
-                                      r'ref tmpl mapfile')
+@attr.s(frozen=True)
+class templatespec(object):
+    ref = attr.ib()
+    tmpl = attr.ib()
+    mapfile = attr.ib()
 
 def lookuptemplate(ui, topic, tmpl):
     """Find the template matching the given -T/--template spec 'tmpl'