Patchwork D7262: templateutil: fix a missing ABCMeta assignment

login
register
mail settings
Submitter phabricator
Date Nov. 6, 2019, 10:56 p.m.
Message ID <differential-rev-PHID-DREV-7mwmhem2yod77u73mswa-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42815/
State Superseded
Headers show

Comments

phabricator - Nov. 6, 2019, 10:56 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Caught by pytype.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7262

AFFECTED FILES
  mercurial/templateutil.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 7, 2019, 8:21 a.m.
dlax added inline comments.

INLINE COMMENTS

> templateutil.py:114
>  
> +    __metaclass__ = abc.ABCMeta
> +

This is ignored on Python 3 (meaning it's possible to instantiate `mappable` directly, despite some methods being abstract). It should be `class mappable(metaclass=abc.ABCMeta)` on Python 3. 
But I realize that there are other `__metaclass__ = abc.ABCMeta` in the code base. Do we handle this somehow or has this been overlooked?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7262/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7262

To: durin42, #hg-reviewers, indygreg
Cc: dlax, mercurial-devel
phabricator - Nov. 7, 2019, 8:26 a.m.
dlax added inline comments.

INLINE COMMENTS

> dlax wrote in templateutil.py:114
> This is ignored on Python 3 (meaning it's possible to instantiate `mappable` directly, despite some methods being abstract). It should be `class mappable(metaclass=abc.ABCMeta)` on Python 3. 
> But I realize that there are other `__metaclass__ = abc.ABCMeta` in the code base. Do we handle this somehow or has this been overlooked?

Just seen D7272 <https://phab.mercurial-scm.org/D7272> and others which explain this. Nevermind.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7262/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7262

To: durin42, #hg-reviewers, indygreg
Cc: dlax, mercurial-devel

Patch

diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py
--- a/mercurial/templateutil.py
+++ b/mercurial/templateutil.py
@@ -111,6 +111,8 @@ 
 class mappable(object):
     """Object which can be converted to a single template mapping"""
 
+    __metaclass__ = abc.ABCMeta
+
     def itermaps(self, context):
         yield self.tomap(context)