changeset 35872:68dc621fa06c

wireprotoserver: make abstractserverproto a proper abstract base class Plug in the abc module so we can have run-time validation of type conformance. Differential Revision: https://phab.mercurial-scm.org/D1990
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 31 Jan 2018 11:30:16 -0800
parents 49ea1ba15ffd
children 29759c46aa1a
files mercurial/wireprotoserver.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py	Wed Jan 31 11:26:03 2018 -0800
+++ b/mercurial/wireprotoserver.py	Wed Jan 31 11:30:16 2018 -0800
@@ -6,6 +6,7 @@
 
 from __future__ import absolute_import
 
+import abc
 import cgi
 import struct
 import sys
@@ -37,12 +38,15 @@
     Used as reference and documentation.
     """
 
+    __metaclass__ = abc.ABCMeta
+
+    @abc.abstractmethod
     def getargs(self, args):
         """return the value for arguments in <args>
 
         returns a list of values (same order as <args>)"""
-        raise NotImplementedError()
 
+    @abc.abstractmethod
     def getfile(self, fp):
         """write the whole content of a file into a file like object
 
@@ -52,13 +56,12 @@
 
         chunk size is the ascii version of the int.
         """
-        raise NotImplementedError()
 
+    @abc.abstractmethod
     def redirect(self):
         """may setup interception for stdout and stderr
 
         See also the `restore` method."""
-        raise NotImplementedError()
 
     # If the `redirect` function does install interception, the `restore`
     # function MUST be defined. If interception is not used, this function